@umituz/react-native-design-system 1.15.0 → 2.0.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.
Files changed (88) hide show
  1. package/package.json +26 -19
  2. package/src/atoms/AtomicAvatar.tsx +161 -0
  3. package/src/atoms/AtomicButton.tsx +241 -0
  4. package/src/atoms/AtomicCard.tsx +84 -0
  5. package/src/atoms/AtomicChip.tsx +226 -0
  6. package/src/atoms/AtomicDatePicker.tsx +255 -0
  7. package/src/atoms/AtomicFab.tsx +99 -0
  8. package/src/atoms/AtomicIcon.tsx +149 -0
  9. package/src/atoms/AtomicInput.tsx +308 -0
  10. package/src/atoms/AtomicPicker.tsx +310 -0
  11. package/src/atoms/AtomicProgress.tsx +149 -0
  12. package/src/atoms/AtomicText.tsx +55 -0
  13. package/src/atoms/__tests__/AtomicButton.test.tsx +107 -0
  14. package/src/atoms/__tests__/AtomicIcon.test.tsx +110 -0
  15. package/src/atoms/__tests__/AtomicInput.test.tsx +195 -0
  16. package/src/atoms/datepicker/components/DatePickerButton.tsx +112 -0
  17. package/src/atoms/datepicker/components/DatePickerModal.tsx +143 -0
  18. package/src/atoms/fab/styles/fabStyles.ts +98 -0
  19. package/src/atoms/fab/types/index.ts +88 -0
  20. package/src/atoms/index.ts +70 -0
  21. package/src/atoms/input/hooks/useInputState.ts +63 -0
  22. package/src/atoms/input/styles/inputStylesHelper.ts +120 -0
  23. package/src/atoms/picker/components/PickerChips.tsx +57 -0
  24. package/src/atoms/picker/components/PickerModal.tsx +214 -0
  25. package/src/atoms/picker/styles/pickerStyles.ts +223 -0
  26. package/src/atoms/picker/types/index.ts +42 -0
  27. package/src/index.ts +133 -52
  28. package/src/molecules/ConfirmationModal.tsx +42 -0
  29. package/src/molecules/ConfirmationModalContent.tsx +87 -0
  30. package/src/molecules/ConfirmationModalMain.tsx +91 -0
  31. package/src/molecules/FormField.tsx +155 -0
  32. package/src/molecules/IconContainer.tsx +79 -0
  33. package/src/molecules/ListItem.tsx +35 -0
  34. package/src/molecules/ScreenHeader.tsx +171 -0
  35. package/src/molecules/SearchBar.tsx +198 -0
  36. package/src/molecules/confirmation-modal/components.tsx +94 -0
  37. package/src/molecules/confirmation-modal/index.ts +7 -0
  38. package/src/molecules/confirmation-modal/styles/confirmationModalStyles.ts +133 -0
  39. package/src/molecules/confirmation-modal/types/index.ts +41 -0
  40. package/src/molecules/confirmation-modal/useConfirmationModal.ts +50 -0
  41. package/src/molecules/index.ts +19 -0
  42. package/src/molecules/listitem/index.ts +6 -0
  43. package/src/molecules/listitem/styles/listItemStyles.ts +37 -0
  44. package/src/molecules/listitem/types/index.ts +21 -0
  45. package/src/organisms/AppHeader.tsx +136 -0
  46. package/src/organisms/FormContainer.tsx +169 -0
  47. package/src/organisms/ScreenLayout.tsx +183 -0
  48. package/src/organisms/index.ts +31 -0
  49. package/src/responsive/config.ts +139 -0
  50. package/src/responsive/deviceDetection.ts +155 -0
  51. package/src/responsive/gridUtils.ts +79 -0
  52. package/src/responsive/index.ts +52 -0
  53. package/src/responsive/platformConstants.ts +98 -0
  54. package/src/responsive/responsive.ts +61 -0
  55. package/src/responsive/responsiveLayout.ts +137 -0
  56. package/src/responsive/responsiveSizing.ts +134 -0
  57. package/src/responsive/useResponsive.ts +140 -0
  58. package/src/responsive/validation.ts +158 -0
  59. package/src/theme/core/BaseTokens.ts +42 -0
  60. package/src/theme/core/ColorPalette.ts +29 -0
  61. package/src/theme/core/CustomColors.ts +122 -0
  62. package/src/theme/core/NavigationTheme.ts +72 -0
  63. package/src/theme/core/TokenFactory.ts +103 -0
  64. package/src/theme/core/colors/ColorUtils.ts +53 -0
  65. package/src/theme/core/colors/DarkColors.ts +146 -0
  66. package/src/theme/core/colors/LightColors.ts +146 -0
  67. package/src/theme/core/constants/DesignConstants.ts +31 -0
  68. package/src/theme/core/themes.ts +118 -0
  69. package/src/theme/core/tokens/BaseTokens.ts +144 -0
  70. package/src/theme/core/tokens/Borders.ts +43 -0
  71. package/src/theme/core/tokens/Sizes.ts +51 -0
  72. package/src/theme/core/tokens/Spacing.ts +38 -0
  73. package/src/theme/core/tokens/Typography.ts +143 -0
  74. package/src/theme/hooks/useAppDesignTokens.ts +45 -0
  75. package/src/theme/hooks/useCommonStyles.ts +248 -0
  76. package/src/theme/hooks/useThemedStyles.ts +68 -0
  77. package/src/theme/index.ts +94 -0
  78. package/src/theme/infrastructure/globalThemeStore.ts +69 -0
  79. package/src/theme/infrastructure/storage/ThemeStorage.ts +93 -0
  80. package/src/theme/infrastructure/stores/themeStore.ts +109 -0
  81. package/src/typography/__tests__/colorValidationUtils.test.ts +180 -0
  82. package/src/typography/__tests__/textColorUtils.test.ts +185 -0
  83. package/src/typography/__tests__/textStyleUtils.test.ts +168 -0
  84. package/src/typography/domain/entities/TypographyTypes.ts +88 -0
  85. package/src/typography/index.ts +53 -0
  86. package/src/typography/presentation/utils/colorValidationUtils.ts +133 -0
  87. package/src/typography/presentation/utils/textColorUtils.ts +205 -0
  88. package/src/typography/presentation/utils/textStyleUtils.ts +159 -0
@@ -0,0 +1,159 @@
1
+ /**
2
+ * Typography Style Utilities
3
+ *
4
+ * Helper functions for resolving typography styles from design tokens.
5
+ * These utilities are used by components to map text style variants
6
+ * to actual style objects from theme.
7
+ *
8
+ * @fileoverview Provides typography style resolution utilities for Material Design 3
9
+ * @author Ümit UZ <umit@umituz.com>
10
+ * @since 1.2.0
11
+ * @version 1.2.0
12
+ *
13
+ * @example
14
+ * ```typescript
15
+ * import { getTextStyle } from '@umituz/react-native-design-system-typography';
16
+ * import { useAppDesignTokens } from '@umituz/react-native-design-system-theme';
17
+ *
18
+ * const MyComponent = () => {
19
+ * const tokens = useAppDesignTokens();
20
+ * const textStyle = getTextStyle('headlineLarge', tokens);
21
+ * return <Text style={textStyle}>Hello</Text>;
22
+ * };
23
+ * ```
24
+ */
25
+
26
+ import type { TextStyle as RNTextStyle } from 'react-native';
27
+
28
+ /**
29
+ * Basic text style interface
30
+ * Compatible with React Native TextStyle
31
+ */
32
+ type TextStyle = RNTextStyle;
33
+
34
+ import type { TextStyleVariant } from '../../domain/entities/TypographyTypes';
35
+ import type { DesignTokens } from '../../../theme';
36
+
37
+ // Cache for text style variant validation to improve performance
38
+ const TEXT_STYLE_VARIANT_SET = new Set<string>([
39
+ 'displayLarge',
40
+ 'displayMedium',
41
+ 'displaySmall',
42
+ 'headlineLarge',
43
+ 'headlineMedium',
44
+ 'headlineSmall',
45
+ 'titleLarge',
46
+ 'titleMedium',
47
+ 'titleSmall',
48
+ 'bodyLarge',
49
+ 'bodyMedium',
50
+ 'bodySmall',
51
+ 'labelLarge',
52
+ 'labelMedium',
53
+ 'labelSmall',
54
+ ]);
55
+
56
+ /**
57
+ * Typography style mapper interface for dependency injection
58
+ */
59
+ interface TypographyStyleMapper {
60
+ getStyle(variant: TextStyleVariant, tokens: DesignTokens): TextStyle;
61
+ }
62
+
63
+ /**
64
+ * Material Design 3 typography style mapper implementation
65
+ */
66
+ class MaterialTypographyMapper implements TypographyStyleMapper {
67
+ getStyle(variant: TextStyleVariant, tokens: DesignTokens): TextStyle {
68
+ const style = tokens.typography[variant] || tokens.typography.bodyLarge;
69
+ return style as TextStyle;
70
+ }
71
+ }
72
+
73
+ // Singleton instance for performance
74
+ const typographyMapper = new MaterialTypographyMapper();
75
+
76
+ // Cache for resolved typography styles to improve performance
77
+ const typographyCache = new Map<string, TextStyle>();
78
+
79
+ /**
80
+ * Clear typography cache
81
+ * Useful for testing or theme changes
82
+ */
83
+ export function clearTypographyCache(): void {
84
+ typographyCache.clear();
85
+ }
86
+
87
+ /**
88
+ * Get typography style from design tokens based on text style variant
89
+ *
90
+ * @param variant - Text style variant
91
+ * @param tokens - Design tokens containing typography values
92
+ * @returns Resolved typography style object
93
+ *
94
+ * @example
95
+ * ```tsx
96
+ * const tokens = useAppDesignTokens();
97
+ * const textStyle = getTextStyle('headlineLarge', tokens);
98
+ * // Returns: { fontSize: 32, fontWeight: '400' }
99
+ * ```
100
+ */
101
+ export function getTextStyle(
102
+ variant: TextStyleVariant,
103
+ tokens: DesignTokens,
104
+ ): TextStyle {
105
+ // Validate tokens parameter
106
+ if (!tokens || !tokens.typography) {
107
+ throw new Error('Invalid design tokens: tokens and tokens.typography are required');
108
+ }
109
+
110
+ // Create cache key - use hash instead of JSON.stringify to prevent memory leaks
111
+ const cacheKey = `${variant}_${Object.keys(tokens.typography).length}_${tokens.typography.bodyLarge?.fontSize || 16}`;
112
+
113
+ // Check cache first
114
+ if (typographyCache.has(cacheKey)) {
115
+ return typographyCache.get(cacheKey)!;
116
+ }
117
+
118
+ // Resolve style and cache it
119
+ const resolvedStyle = typographyMapper.getStyle(variant, tokens);
120
+ typographyCache.set(cacheKey, resolvedStyle);
121
+
122
+ return resolvedStyle;
123
+ }
124
+
125
+ /**
126
+ * Check if a string is a valid TextStyleVariant
127
+ * Uses Set for O(1) lookup performance
128
+ *
129
+ * @param value - String to check
130
+ * @returns True if value is a TextStyleVariant
131
+ */
132
+ export function isTextStyleVariant(value: string): value is TextStyleVariant {
133
+ return TEXT_STYLE_VARIANT_SET.has(value);
134
+ }
135
+
136
+ /**
137
+ * Get all available text style variants
138
+ *
139
+ * @returns Array of all TextStyleVariant values
140
+ */
141
+ export function getAllTextStyleVariants(): TextStyleVariant[] {
142
+ return [
143
+ 'displayLarge',
144
+ 'displayMedium',
145
+ 'displaySmall',
146
+ 'headlineLarge',
147
+ 'headlineMedium',
148
+ 'headlineSmall',
149
+ 'titleLarge',
150
+ 'titleMedium',
151
+ 'titleSmall',
152
+ 'bodyLarge',
153
+ 'bodyMedium',
154
+ 'bodySmall',
155
+ 'labelLarge',
156
+ 'labelMedium',
157
+ 'labelSmall',
158
+ ];
159
+ }