@umituz/react-native-design-system 4.25.7 → 4.25.9

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 (82) hide show
  1. package/package.json +1 -1
  2. package/src/atoms/AtomicAvatar.tsx +0 -5
  3. package/src/atoms/AtomicInput.tsx +0 -2
  4. package/src/atoms/AtomicProgress.tsx +0 -5
  5. package/src/atoms/AtomicTextArea.tsx +0 -4
  6. package/src/atoms/card/AtomicCard.tsx +111 -54
  7. package/src/atoms/input/types.ts +0 -2
  8. package/src/atoms/skeleton/AtomicSkeleton.tsx +2 -2
  9. package/src/image/presentation/components/ImageGallery.tsx +16 -15
  10. package/src/image/presentation/components/editor/StickerPickerSheet.tsx +4 -7
  11. package/src/index.ts +12 -55
  12. package/src/layouts/ScreenHeader/ScreenHeader.tsx +0 -2
  13. package/src/loading/presentation/providers/LoadingProvider.tsx +13 -4
  14. package/src/molecules/SearchBar/SearchBar.tsx +0 -2
  15. package/src/molecules/SearchBar/SearchSuggestions.tsx +1 -1
  16. package/src/molecules/SearchBar/types.ts +0 -1
  17. package/src/molecules/StepHeader/StepHeader.tsx +1 -1
  18. package/src/molecules/avatar/Avatar.tsx +76 -71
  19. package/src/molecules/avatar/AvatarGroup.tsx +1 -1
  20. package/src/molecules/calendar/presentation/components/CalendarDayCell.tsx +2 -3
  21. package/src/molecules/calendar/presentation/components/CalendarWeekdayHeader.tsx +1 -1
  22. package/src/molecules/countdown/components/Countdown.tsx +14 -11
  23. package/src/molecules/info-grid/InfoGrid.tsx +2 -2
  24. package/src/onboarding/presentation/components/BackgroundImageCollage.tsx +2 -2
  25. package/src/onboarding/presentation/components/OnboardingBackground.tsx +63 -49
  26. package/src/onboarding/presentation/components/OnboardingSlide.tsx +2 -2
  27. package/src/theme/infrastructure/providers/DesignSystemProvider.tsx +3 -1
  28. package/src/gallery/gallery-download.service.ts +0 -69
  29. package/src/gallery/gallery-save.service.ts +0 -80
  30. package/src/gallery/index.ts +0 -3
  31. package/src/gallery/types.ts +0 -11
  32. package/src/image/domain/entities/EditorTypes.ts +0 -23
  33. package/src/image/domain/entities/editor/EditorConfigTypes.ts +0 -35
  34. package/src/image/domain/entities/editor/EditorElementTypes.ts +0 -60
  35. package/src/image/domain/entities/editor/EditorFilterTypes.ts +0 -9
  36. package/src/image/domain/entities/editor/EditorLayerTypes.ts +0 -34
  37. package/src/image/domain/entities/editor/EditorStateTypes.ts +0 -35
  38. package/src/image/domain/entities/editor/EditorToolTypes.ts +0 -33
  39. package/src/image/infrastructure/services/ImageEditorService.ts +0 -134
  40. package/src/image/infrastructure/utils/ImageAnalysisUtils.ts +0 -120
  41. package/src/image/infrastructure/utils/ImageEditorHistoryUtils.ts +0 -63
  42. package/src/image/infrastructure/utils/LayerManager.ts +0 -65
  43. package/src/media/infrastructure/hooks/useGenericMediaGeneration.ts +0 -170
  44. package/src/molecules/ConfirmationModal.tsx +0 -42
  45. package/src/molecules/calendar/infrastructure/storage/CalendarStore.types.ts +0 -64
  46. package/src/molecules/calendar/infrastructure/storage/CalendarStore.utils.ts +0 -56
  47. package/src/molecules/calendar/infrastructure/storage/EventActions.ts +0 -140
  48. package/src/molecules/calendar/infrastructure/storage/NavigationActions.ts +0 -118
  49. package/src/molecules/calendar/presentation/hooks/useCalendar.ts +0 -185
  50. package/src/molecules/confirmation-modal/index.ts +0 -7
  51. package/src/molecules/listitem/index.ts +0 -6
  52. package/src/molecules/navigation/components/index.ts +0 -4
  53. package/src/molecules/navigation/utils/NavigationTheme.ts +0 -21
  54. package/src/presentation/utils/variants/compound.ts +0 -34
  55. package/src/services/api/ApiClient.ts +0 -180
  56. package/src/services/api/index.ts +0 -9
  57. package/src/services/api/types/ApiTypes.ts +0 -50
  58. package/src/services/api/utils/requestBuilder.ts +0 -92
  59. package/src/services/api/utils/responseHandler.ts +0 -130
  60. package/src/storage/cache/index.ts +0 -28
  61. package/src/theme/core/tokens/BorderRadius.ts +0 -16
  62. package/src/utilities/clipboard/ClipboardUtils.ts +0 -67
  63. package/src/utilities/clipboard/index.ts +0 -5
  64. package/src/utilities/index.ts +0 -6
  65. package/src/utilities/sharing/domain/entities/Share.ts +0 -104
  66. package/src/utilities/sharing/domain/entities/SharingUtils.ts +0 -111
  67. package/src/utilities/sharing/index.ts +0 -33
  68. package/src/utilities/sharing/infrastructure/services/SharingService.ts +0 -165
  69. package/src/utilities/sharing/presentation/hooks/useSharing.ts +0 -116
  70. package/src/utils/colorMapper.ts +0 -193
  71. package/src/utils/errors/adapters/CacheErrorAdapter.ts +0 -68
  72. package/src/utils/errors/adapters/ImageErrorAdapter.ts +0 -91
  73. package/src/utils/errors/adapters/StorageErrorAdapter.ts +0 -107
  74. package/src/utils/formatHelper.ts +0 -16
  75. package/src/utils/formatters/dateFormatter.ts +0 -64
  76. package/src/utils/formatters/numberFormatter.ts +0 -130
  77. package/src/utils/index.ts +0 -16
  78. package/src/utils/styleComposer.ts +0 -94
  79. package/src/utils/validationHelper.ts +0 -16
  80. package/src/utils/validators/dataValidators.ts +0 -111
  81. package/src/utils/validators/numericValidators.ts +0 -106
  82. package/src/utils/validators/stringValidators.ts +0 -85
@@ -1,116 +0,0 @@
1
- /**
2
- * Sharing Domain - useSharing Hook
3
- *
4
- * React hook for sharing files.
5
- * Provides system share sheet functionality with state management.
6
- *
7
- * @domain sharing
8
- * @layer presentation/hooks
9
- */
10
-
11
- import { useCallback, useMemo } from 'react';
12
- import { SharingService } from '../../infrastructure/services/SharingService';
13
- import type { ShareOptions } from '../../domain/entities/Share';
14
- import { useAsyncOperation } from '../../../../utils/hooks';
15
-
16
- /**
17
- * useSharing hook for sharing files via system share sheet
18
- */
19
- export const useSharing = () => {
20
- // Check availability on mount
21
- const availabilityOp = useAsyncOperation<boolean, string>(
22
- () => SharingService.isAvailable(),
23
- {
24
- immediate: true,
25
- initialData: false,
26
- errorHandler: () => 'Failed to check sharing availability',
27
- }
28
- );
29
-
30
- // Share operations
31
- const shareOp = useAsyncOperation<boolean, string>(
32
- async (uri: string, options?: ShareOptions) => {
33
- const result = await SharingService.shareFile(uri, options);
34
- if (!result.success) {
35
- throw new Error(result.error || 'Failed to share file');
36
- }
37
- return true;
38
- },
39
- {
40
- immediate: false,
41
- errorHandler: (err) => err instanceof Error ? err.message : 'Failed to share file',
42
- }
43
- );
44
-
45
- const shareWithAutoTypeOp = useAsyncOperation<boolean, string>(
46
- async (uri: string, filename: string, dialogTitle?: string) => {
47
- const result = await SharingService.shareWithAutoType(uri, filename, dialogTitle);
48
- if (!result.success) {
49
- throw new Error(result.error || 'Failed to share file');
50
- }
51
- return true;
52
- },
53
- {
54
- immediate: false,
55
- errorHandler: (err) => err instanceof Error ? err.message : 'Failed to share file',
56
- }
57
- );
58
-
59
- const shareMultipleOp = useAsyncOperation<boolean, string>(
60
- async (uris: string[], options?: ShareOptions) => {
61
- const result = await SharingService.shareMultipleFiles(uris, options);
62
- if (!result.success) {
63
- throw new Error(result.error || 'Failed to share files');
64
- }
65
- return true;
66
- },
67
- {
68
- immediate: false,
69
- errorHandler: (err) => err instanceof Error ? err.message : 'Failed to share files',
70
- }
71
- );
72
-
73
- const share = useCallback(
74
- async (uri: string, options?: ShareOptions): Promise<boolean> => {
75
- const result = await shareOp.execute(uri, options);
76
- return result ?? false;
77
- },
78
- [shareOp]
79
- );
80
-
81
- const shareWithAutoType = useCallback(
82
- async (uri: string, filename: string, dialogTitle?: string): Promise<boolean> => {
83
- const result = await shareWithAutoTypeOp.execute(uri, filename, dialogTitle);
84
- return result ?? false;
85
- },
86
- [shareWithAutoTypeOp]
87
- );
88
-
89
- const shareMultiple = useCallback(
90
- async (uris: string[], options?: ShareOptions): Promise<boolean> => {
91
- const result = await shareMultipleOp.execute(uris, options);
92
- return result ?? false;
93
- },
94
- [shareMultipleOp]
95
- );
96
-
97
- return useMemo(() => ({
98
- share,
99
- shareWithAutoType,
100
- shareMultiple,
101
- isAvailable: availabilityOp.data ?? false,
102
- isSharing: shareOp.isLoading || shareWithAutoTypeOp.isLoading || shareMultipleOp.isLoading,
103
- error: shareOp.error || shareWithAutoTypeOp.error || shareMultipleOp.error,
104
- }), [
105
- share,
106
- shareWithAutoType,
107
- shareMultiple,
108
- availabilityOp.data,
109
- shareOp.isLoading,
110
- shareWithAutoTypeOp.isLoading,
111
- shareMultipleOp.isLoading,
112
- shareOp.error,
113
- shareWithAutoTypeOp.error,
114
- shareMultipleOp.error,
115
- ]);
116
- };
@@ -1,193 +0,0 @@
1
- /**
2
- * Color Mapper Utility
3
- * Centralized color mapping logic for consistent theming
4
- */
5
-
6
- import type { DesignTokens } from '../theme';
7
-
8
- /**
9
- * Standard color variants available in the design system
10
- */
11
- export type ColorVariant =
12
- | 'primary'
13
- | 'secondary'
14
- | 'tertiary'
15
- | 'success'
16
- | 'warning'
17
- | 'error'
18
- | 'info'
19
- | 'surface'
20
- | 'background'
21
- | 'text'
22
- | 'border'
23
- | 'disabled';
24
-
25
- /**
26
- * Color intensity levels
27
- */
28
- export type ColorIntensity = 'primary' | 'secondary' | 'light' | 'dark';
29
-
30
- /**
31
- * Maps a color variant to actual color value from tokens
32
- *
33
- * @param variant - Color variant to map
34
- * @param tokens - Design tokens containing color definitions
35
- * @param intensity - Optional color intensity level
36
- * @returns Hex color string
37
- */
38
- export function mapColorVariant(
39
- variant: ColorVariant,
40
- tokens: DesignTokens,
41
- intensity: ColorIntensity = 'primary'
42
- ): string {
43
- const colors = tokens.colors as any;
44
-
45
- const colorMap: Record<ColorVariant, Record<ColorIntensity, string>> = {
46
- primary: {
47
- primary: colors.primary,
48
- secondary: colors.primarySecondary || colors.primary,
49
- light: colors.primaryLight || colors.primary,
50
- dark: colors.primaryDark || colors.primary,
51
- },
52
- secondary: {
53
- primary: colors.secondary,
54
- secondary: colors.secondarySecondary || colors.secondary,
55
- light: colors.secondaryLight || colors.secondary,
56
- dark: colors.secondaryDark || colors.secondary,
57
- },
58
- tertiary: {
59
- primary: colors.tertiary || colors.primary,
60
- secondary: colors.tertiary || colors.primary,
61
- light: colors.tertiary || colors.primary,
62
- dark: colors.tertiary || colors.primary,
63
- },
64
- success: {
65
- primary: colors.success || '#4CAF50',
66
- secondary: colors.successSecondary || '#81C784',
67
- light: colors.successLight || '#A5D6A7',
68
- dark: colors.successDark || '#388E3C',
69
- },
70
- warning: {
71
- primary: colors.warning || '#FF9800',
72
- secondary: colors.warningSecondary || '#FFB74D',
73
- light: colors.warningLight || '#FFCC80',
74
- dark: colors.warningDark || '#F57C00',
75
- },
76
- error: {
77
- primary: colors.error || '#F44336',
78
- secondary: colors.errorSecondary || '#E57373',
79
- light: colors.errorLight || '#EF9A9A',
80
- dark: colors.errorDark || '#D32F2F',
81
- },
82
- info: {
83
- primary: colors.info || '#2196F3',
84
- secondary: colors.infoSecondary || '#64B5F6',
85
- light: colors.infoLight || '#90CAF9',
86
- dark: colors.infoDark || '#1976D2',
87
- },
88
- surface: {
89
- primary: colors.surface,
90
- secondary: colors.surfaceSecondary || colors.surface,
91
- light: colors.surfaceLight || colors.surface,
92
- dark: colors.surfaceDark || colors.surface,
93
- },
94
- background: {
95
- primary: colors.backgroundPrimary,
96
- secondary: colors.backgroundSecondary || colors.backgroundPrimary,
97
- light: colors.backgroundLight || colors.backgroundPrimary,
98
- dark: colors.backgroundDark || colors.backgroundPrimary,
99
- },
100
- text: {
101
- primary: colors.textPrimary,
102
- secondary: colors.textSecondary,
103
- light: colors.textLight || colors.textPrimary,
104
- dark: colors.textDark || colors.textPrimary,
105
- },
106
- border: {
107
- primary: colors.borderLight,
108
- secondary: colors.borderMedium || colors.borderLight,
109
- light: colors.borderLight,
110
- dark: colors.borderDark || colors.borderLight,
111
- },
112
- disabled: {
113
- primary: colors.disabled || colors.textSecondary,
114
- secondary: colors.disabledSecondary || colors.disabled || colors.textSecondary,
115
- light: colors.disabledLight || colors.disabled || colors.textSecondary,
116
- dark: colors.disabledDark || colors.disabled || colors.textSecondary,
117
- },
118
- };
119
-
120
- return colorMap[variant]?.[intensity] || colors.primary;
121
- }
122
-
123
- /**
124
- * Creates a color mapping object for components
125
- * Useful for icon colors, button colors, etc.
126
- *
127
- * @param tokens - Design tokens
128
- * @param colorKeys - Array of color keys to map
129
- * @returns Object mapping color keys to values
130
- */
131
- export function createColorMap(
132
- tokens: DesignTokens,
133
- colorKeys: ColorVariant[]
134
- ): Record<string, string> {
135
- const colorMap: Record<string, string> = {};
136
-
137
- colorKeys.forEach((key) => {
138
- colorMap[key] = mapColorVariant(key, tokens);
139
- });
140
-
141
- return colorMap;
142
- }
143
-
144
- /**
145
- * Gets text color based on background color for contrast
146
- *
147
- * @param backgroundColor - Background color hex value
148
- * @returns Appropriate text color (light or dark)
149
- */
150
- export function getContrastTextColor(backgroundColor: string): string {
151
- const hex = backgroundColor.replace('#', '');
152
- const r = parseInt(hex.substr(0, 2), 16);
153
- const g = parseInt(hex.substr(2, 2), 16);
154
- const b = parseInt(hex.substr(4, 2), 16);
155
-
156
- // Calculate luminance
157
- const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
158
-
159
- return luminance > 0.5 ? '#000000' : '#FFFFFF';
160
- }
161
-
162
- /**
163
- * Checks if a color is light
164
- *
165
- * @param color - Hex color string
166
- * @returns True if color is light
167
- */
168
- export function isLightColor(color: string): boolean {
169
- const hex = color.replace('#', '');
170
- const r = parseInt(hex.substr(0, 2), 16);
171
- const g = parseInt(hex.substr(2, 2), 16);
172
- const b = parseInt(hex.substr(4, 2), 16);
173
-
174
- const luminance = (0.299 * r + 0.587 * g + 0.114 * b) / 255;
175
-
176
- return luminance > 0.5;
177
- }
178
-
179
- /**
180
- * Adjusts color opacity
181
- *
182
- * @param color - Hex color string
183
- * @param opacity - Opacity value (0-1)
184
- * @returns RGBA color string
185
- */
186
- export function adjustColorOpacity(color: string, opacity: number): string {
187
- const hex = color.replace('#', '');
188
- const r = parseInt(hex.substr(0, 2), 16);
189
- const g = parseInt(hex.substr(2, 2), 16);
190
- const b = parseInt(hex.substr(4, 2), 16);
191
-
192
- return `rgba(${r}, ${g}, ${b}, ${opacity})`;
193
- }
@@ -1,68 +0,0 @@
1
- /**
2
- * Cache Error Adapter
3
- *
4
- * Adapts cache errors to unified DesignSystemError format.
5
- * Maintains backward compatibility with CacheError.
6
- */
7
-
8
- import { DesignSystemError, ErrorCodes, ErrorCategory } from '../DesignSystemError';
9
- import type { ErrorMetadata } from '../DesignSystemError';
10
- import { CacheError } from '../../../storage/cache/domain/ErrorHandler';
11
-
12
- export class CacheErrorAdapter {
13
- /**
14
- * Create a DesignSystemError for cache operations
15
- */
16
- static create(message: string, context: string, cause?: unknown): DesignSystemError {
17
- const metadata: ErrorMetadata = {
18
- category: ErrorCategory.CACHE,
19
- operation: context,
20
- cause,
21
- retryable: true,
22
- };
23
-
24
- return new DesignSystemError(
25
- `${context}: ${message}`,
26
- ErrorCodes.CACHE_ERROR,
27
- { context },
28
- metadata
29
- );
30
- }
31
-
32
- /**
33
- * Convert legacy CacheError to DesignSystemError
34
- */
35
- static fromCacheError(error: CacheError): DesignSystemError {
36
- return new DesignSystemError(
37
- error.message,
38
- ErrorCodes.CACHE_ERROR,
39
- { cacheErrorCode: error.code },
40
- {
41
- category: ErrorCategory.CACHE,
42
- retryable: true,
43
- }
44
- );
45
- }
46
-
47
- /**
48
- * Handle with timeout (replaces cache ErrorHandler.withTimeout)
49
- */
50
- static async withTimeout<T>(
51
- promise: Promise<T>,
52
- timeoutMs: number,
53
- context: string
54
- ): Promise<T> {
55
- const timeoutPromise = new Promise<never>((_, reject) => {
56
- setTimeout(() => {
57
- reject(
58
- this.create(
59
- `Operation timed out after ${timeoutMs}ms`,
60
- context
61
- )
62
- );
63
- }, timeoutMs);
64
- });
65
-
66
- return Promise.race([promise, timeoutPromise]);
67
- }
68
- }
@@ -1,91 +0,0 @@
1
- /**
2
- * Image Error Adapter
3
- *
4
- * Adapts image errors to unified DesignSystemError format.
5
- * Maintains backward compatibility with ImageError.
6
- */
7
-
8
- import { DesignSystemError, ErrorCodes, ErrorCategory } from '../DesignSystemError';
9
- import type { ErrorMetadata } from '../DesignSystemError';
10
- import {
11
- ImageError,
12
- IMAGE_ERROR_CODES,
13
- type ImageErrorCode,
14
- } from '../../../image/infrastructure/utils/ImageErrorHandler';
15
-
16
- export class ImageErrorAdapter {
17
- /**
18
- * Map ImageErrorCode to DesignSystemError code
19
- */
20
- private static mapErrorCode(code: ImageErrorCode): string {
21
- switch (code) {
22
- case IMAGE_ERROR_CODES.INVALID_URI:
23
- case IMAGE_ERROR_CODES.INVALID_DIMENSIONS:
24
- case IMAGE_ERROR_CODES.INVALID_QUALITY:
25
- case IMAGE_ERROR_CODES.VALIDATION_ERROR:
26
- return ErrorCodes.VALIDATION_ERROR;
27
-
28
- case IMAGE_ERROR_CODES.MANIPULATION_FAILED:
29
- case IMAGE_ERROR_CODES.CONVERSION_FAILED:
30
- return ErrorCodes.IMAGE_LOAD_ERROR;
31
-
32
- case IMAGE_ERROR_CODES.STORAGE_FAILED:
33
- return ErrorCodes.STORAGE_ERROR;
34
-
35
- default:
36
- return ErrorCodes.UNKNOWN_ERROR;
37
- }
38
- }
39
-
40
- /**
41
- * Create a DesignSystemError for image operations
42
- */
43
- static create(
44
- message: string,
45
- code: ImageErrorCode,
46
- operation?: string
47
- ): DesignSystemError {
48
- const metadata: ErrorMetadata = {
49
- category: ErrorCategory.IMAGE,
50
- operation,
51
- retryable: code === IMAGE_ERROR_CODES.MANIPULATION_FAILED,
52
- };
53
-
54
- return new DesignSystemError(
55
- message,
56
- this.mapErrorCode(code),
57
- { imageErrorCode: code, operation },
58
- metadata
59
- );
60
- }
61
-
62
- /**
63
- * Convert legacy ImageError to DesignSystemError
64
- */
65
- static fromImageError(error: ImageError): DesignSystemError {
66
- return this.create(error.message, error.code as ImageErrorCode, error.operation);
67
- }
68
-
69
- /**
70
- * Handle unknown image errors
71
- */
72
- static handleUnknown(error: unknown, operation?: string): DesignSystemError {
73
- if (error instanceof ImageError) {
74
- return this.fromImageError(error);
75
- }
76
-
77
- const message = error instanceof Error ? error.message : 'Unknown image error occurred';
78
-
79
- return new DesignSystemError(
80
- message,
81
- ErrorCodes.IMAGE_LOAD_ERROR,
82
- { operation },
83
- {
84
- category: ErrorCategory.IMAGE,
85
- operation,
86
- cause: error,
87
- retryable: true,
88
- }
89
- );
90
- }
91
- }
@@ -1,107 +0,0 @@
1
- /**
2
- * Storage Error Adapter
3
- *
4
- * Adapts storage errors to unified DesignSystemError format.
5
- * Maintains backward compatibility with StorageError hierarchy.
6
- */
7
-
8
- import { DesignSystemError, ErrorCodes, ErrorCategory } from '../DesignSystemError';
9
- import type { ErrorMetadata } from '../DesignSystemError';
10
- import {
11
- StorageError,
12
- StorageReadError,
13
- StorageWriteError,
14
- StorageDeleteError,
15
- StorageSerializationError,
16
- StorageDeserializationError,
17
- } from '../../../storage/domain/errors/StorageError';
18
-
19
- export class StorageErrorAdapter {
20
- /**
21
- * Create a DesignSystemError for storage read failures
22
- */
23
- static readError(key: string, cause?: unknown): DesignSystemError {
24
- const metadata: ErrorMetadata = {
25
- category: ErrorCategory.STORAGE,
26
- operation: 'read',
27
- key,
28
- cause,
29
- retryable: true,
30
- };
31
-
32
- return new DesignSystemError(
33
- `Failed to read from storage: ${key}`,
34
- ErrorCodes.STORAGE_ERROR,
35
- { key },
36
- metadata
37
- );
38
- }
39
-
40
- /**
41
- * Create a DesignSystemError for storage write failures
42
- */
43
- static writeError(key: string, cause?: unknown): DesignSystemError {
44
- const metadata: ErrorMetadata = {
45
- category: ErrorCategory.STORAGE,
46
- operation: 'write',
47
- key,
48
- cause,
49
- retryable: true,
50
- };
51
-
52
- return new DesignSystemError(
53
- `Failed to write to storage: ${key}`,
54
- ErrorCodes.STORAGE_ERROR,
55
- { key },
56
- metadata
57
- );
58
- }
59
-
60
- /**
61
- * Create a DesignSystemError for storage delete failures
62
- */
63
- static deleteError(key: string, cause?: unknown): DesignSystemError {
64
- const metadata: ErrorMetadata = {
65
- category: ErrorCategory.STORAGE,
66
- operation: 'delete',
67
- key,
68
- cause,
69
- retryable: true,
70
- };
71
-
72
- return new DesignSystemError(
73
- `Failed to delete from storage: ${key}`,
74
- ErrorCodes.STORAGE_ERROR,
75
- { key },
76
- metadata
77
- );
78
- }
79
-
80
- /**
81
- * Convert legacy StorageError to DesignSystemError
82
- */
83
- static fromStorageError(error: StorageError): DesignSystemError {
84
- let operation = 'unknown';
85
-
86
- if (error instanceof StorageReadError) operation = 'read';
87
- else if (error instanceof StorageWriteError) operation = 'write';
88
- else if (error instanceof StorageDeleteError) operation = 'delete';
89
- else if (error instanceof StorageSerializationError) operation = 'serialize';
90
- else if (error instanceof StorageDeserializationError) operation = 'deserialize';
91
-
92
- const cause = 'cause' in error ? error.cause : undefined;
93
-
94
- return new DesignSystemError(
95
- error.message,
96
- ErrorCodes.STORAGE_ERROR,
97
- { key: error.key },
98
- {
99
- category: ErrorCategory.STORAGE,
100
- operation,
101
- key: error.key,
102
- cause,
103
- retryable: true,
104
- }
105
- );
106
- }
107
- }
@@ -1,16 +0,0 @@
1
- /**
2
- * Format Helper Utility
3
- * Common formatting functions for dates, numbers, currency, etc.
4
- *
5
- * This file re-exports all formatting utilities for convenience
6
- */
7
-
8
- // Date formatting
9
- export * from './formatters/dateFormatter';
10
-
11
- // Number, currency, percent formatting
12
- export * from './formatters/numberFormatter';
13
-
14
- // String, phone, file size formatting
15
- export * from './formatters/stringFormatter';
16
-
@@ -1,64 +0,0 @@
1
- /**
2
- * Date Formatter Utility
3
- * Date and time formatting functions
4
- */
5
-
6
- /**
7
- * Date formatting options
8
- */
9
- export interface DateFormatOptions {
10
- format?: 'short' | 'medium' | 'long' | 'full' | 'relative';
11
- locale?: string;
12
- includeTime?: boolean;
13
- }
14
-
15
- /**
16
- * Formats a date according to the specified options
17
- *
18
- * @param date - Date to format
19
- * @param options - Formatting options
20
- * @returns Formatted date string
21
- */
22
- export function formatDate(date: Date | string | number, options: DateFormatOptions = {}): string {
23
- const {
24
- format = 'medium',
25
- locale = 'en-US',
26
- includeTime = false,
27
- } = options;
28
-
29
- const dateObj = typeof date === 'string' || typeof date === 'number'
30
- ? new Date(date)
31
- : date;
32
-
33
- if (isNaN(dateObj.getTime())) {
34
- return 'Invalid Date';
35
- }
36
-
37
- const now = new Date();
38
- const diffMs = now.getTime() - dateObj.getTime();
39
- const diffDays = Math.floor(diffMs / (1000 * 60 * 60 * 24));
40
-
41
- // Relative date formatting for recent dates
42
- if (format === 'relative') {
43
- if (diffDays === 0) return 'Today';
44
- if (diffDays === 1) return 'Yesterday';
45
- if (diffDays === -1) return 'Tomorrow';
46
- if (diffDays < -1 && diffDays > -7) return `${Math.abs(diffDays)} days from now`;
47
- if (diffDays > 1 && diffDays < 7) return `${diffDays} days ago`;
48
- }
49
-
50
- const dateStyle = format === 'short' ? 'short' :
51
- format === 'long' ? 'long' :
52
- format === 'full' ? 'full' : 'medium';
53
-
54
- if (includeTime) {
55
- return new Intl.DateTimeFormat(locale, {
56
- dateStyle,
57
- timeStyle: 'short',
58
- }).format(dateObj);
59
- }
60
-
61
- return new Intl.DateTimeFormat(locale, {
62
- dateStyle,
63
- }).format(dateObj);
64
- }