@umituz/react-native-design-system 2.5.37 → 2.5.41

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@umituz/react-native-design-system",
3
- "version": "2.5.37",
3
+ "version": "2.5.41",
4
4
  "description": "Universal design system for React Native apps - Consolidated package with atoms, molecules, organisms, theme, typography, responsive and safe area utilities",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -129,8 +129,13 @@ export const AtomicIcon: React.FC<AtomicIconProps> = React.memo(({
129
129
  ? getSemanticColor(color, tokens)
130
130
  : tokens.colors.textPrimary;
131
131
 
132
- // Validate icon - use fallback silently if invalid
133
- const iconName = name && name in Ionicons.glyphMap ? name : FALLBACK_ICON;
132
+ // Validate icon - use fallback and log warning in DEV if invalid
133
+ const isInvalidIcon = name && !(name in Ionicons.glyphMap);
134
+ const iconName = name && !isInvalidIcon ? name : FALLBACK_ICON;
135
+
136
+ if (__DEV__ && isInvalidIcon) {
137
+ console.warn(`[DesignSystem] Invalid icon name: "${name}". Falling back to "${FALLBACK_ICON}"`);
138
+ }
134
139
 
135
140
  const iconElement = svgPath ? (
136
141
  <Svg
@@ -197,6 +202,4 @@ const styles = StyleSheet.create({
197
202
  },
198
203
  });
199
204
 
200
- // Legacy type alias for backward compatibility
201
- export type IconProps = AtomicIconProps;
202
205
 
package/src/index.ts CHANGED
@@ -23,6 +23,7 @@ export {
23
23
  useTheme,
24
24
  useThemedStyles,
25
25
  useThemedStyleSheet,
26
+ DesignSystemProvider,
26
27
  lightColors,
27
28
  darkColors,
28
29
  getColorPalette,
@@ -173,7 +173,7 @@ export const ScreenLayout: React.FC<ScreenLayoutProps> = ({
173
173
  flex: 1,
174
174
  width: '100%',
175
175
  maxWidth: finalMaxWidth,
176
- alignSelf: 'center',
176
+ alignSelf: 'flex-start',
177
177
  },
178
178
  content: {
179
179
  flex: 1,
@@ -71,6 +71,12 @@ export { useTheme } from './infrastructure/stores/themeStore';
71
71
  export { useThemedStyles, useThemedStyleSheet } from './hooks/useThemedStyles';
72
72
  export { useCommonStyles } from './hooks/useCommonStyles';
73
73
 
74
+ // =============================================================================
75
+ // PROVIDER
76
+ // =============================================================================
77
+
78
+ export { DesignSystemProvider } from './infrastructure/providers/DesignSystemProvider';
79
+
74
80
  // =============================================================================
75
81
  // THEME OBJECTS
76
82
  // =============================================================================
@@ -0,0 +1,110 @@
1
+ import React, { useEffect, useState, ReactNode } from 'react';
2
+ import { ActivityIndicator, View, StyleSheet } from 'react-native';
3
+ import { useThemeStore } from '../stores/themeStore';
4
+ import { useDesignSystemTheme } from '../globalThemeStore';
5
+ import type { CustomThemeColors } from '../../core/CustomColors';
6
+
7
+ declare const __DEV__: boolean;
8
+
9
+ interface DesignSystemProviderProps {
10
+ /** App content */
11
+ children: ReactNode;
12
+ /** Custom theme colors to override defaults */
13
+ customColors?: CustomThemeColors;
14
+ /** Show loading indicator while initializing (default: false) */
15
+ showLoadingIndicator?: boolean;
16
+ /** Custom loading component */
17
+ loadingComponent?: ReactNode;
18
+ /** Callback when initialization completes */
19
+ onInitialized?: () => void;
20
+ /** Callback when initialization fails */
21
+ onError?: (error: unknown) => void;
22
+ }
23
+
24
+ /**
25
+ * DesignSystemProvider
26
+ *
27
+ * Initializes theme store and applies custom colors.
28
+ * Wrap your app with this provider to enable design system features.
29
+ *
30
+ * Features:
31
+ * - Auto-initializes theme from storage
32
+ * - Supports custom color overrides
33
+ * - Optional loading state
34
+ * - Error handling
35
+ *
36
+ * Usage:
37
+ * ```tsx
38
+ * import { DesignSystemProvider } from '@umituz/react-native-design-system';
39
+ *
40
+ * export default function App() {
41
+ * return (
42
+ * <DesignSystemProvider
43
+ * customColors={{ primary: '#FF6B6B' }}
44
+ * showLoadingIndicator
45
+ * >
46
+ * <YourApp />
47
+ * </DesignSystemProvider>
48
+ * );
49
+ * }
50
+ * ```
51
+ */
52
+ export const DesignSystemProvider: React.FC<DesignSystemProviderProps> = ({
53
+ children,
54
+ customColors,
55
+ showLoadingIndicator = false,
56
+ loadingComponent,
57
+ onInitialized,
58
+ onError,
59
+ }: DesignSystemProviderProps) => {
60
+ const [isInitialized, setIsInitialized] = useState(false);
61
+ const initialize = useThemeStore((state) => state.initialize);
62
+ const setCustomColors = useDesignSystemTheme((state) => state.setCustomColors);
63
+
64
+ useEffect(() => {
65
+ if (__DEV__) console.log('[DesignSystemProvider] Initializing...');
66
+
67
+ // Apply custom colors if provided
68
+ if (customColors) {
69
+ if (__DEV__) console.log('[DesignSystemProvider] Applying custom colors');
70
+ setCustomColors(customColors);
71
+ }
72
+
73
+ // Initialize theme store
74
+ initialize()
75
+ .then(() => {
76
+ if (__DEV__) console.log('[DesignSystemProvider] Initialized successfully');
77
+ setIsInitialized(true);
78
+ onInitialized?.();
79
+ })
80
+ .catch((error) => {
81
+ if (__DEV__) console.error('[DesignSystemProvider] Initialization failed:', error);
82
+ setIsInitialized(true); // Still render app even on error
83
+ onError?.(error);
84
+ });
85
+ }, [initialize, customColors, setCustomColors, onInitialized, onError]);
86
+
87
+ // Show loading indicator if requested and not yet initialized
88
+ if (showLoadingIndicator && !isInitialized) {
89
+ if (loadingComponent) {
90
+ return <>{loadingComponent}</>;
91
+ }
92
+
93
+ return (
94
+ <View style={styles.loadingContainer}>
95
+ <ActivityIndicator size="large" />
96
+ </View>
97
+ );
98
+ }
99
+
100
+ return <>{children}</>;
101
+ };
102
+
103
+ const styles = StyleSheet.create({
104
+ loadingContainer: {
105
+ flex: 1,
106
+ justifyContent: 'center',
107
+ alignItems: 'center',
108
+ backgroundColor: '#000000',
109
+ },
110
+ });
@@ -34,13 +34,15 @@ interface ThemeActions {
34
34
  *
35
35
  * Usage:
36
36
  * ```typescript
37
- * import { useTheme } from '@umituz/react-native-design-system-theme';
37
+ * import { useTheme } from '@umituz/react-native-design-system';
38
38
  *
39
39
  * const MyComponent = () => {
40
40
  * const { theme, themeMode, setThemeMode, toggleTheme } = useTheme();
41
41
  * // ...
42
42
  * };
43
43
  * ```
44
+ *
45
+ * NOTE: Make sure to wrap your app with DesignSystemProvider for auto-initialization
44
46
  */
45
47
  export const useTheme = createStore<ThemeState, ThemeActions>({
46
48
  name: 'theme-store',
@@ -107,8 +109,8 @@ export const useTheme = createStore<ThemeState, ThemeActions>({
107
109
  }),
108
110
  });
109
111
 
110
-
111
-
112
+ // Export internal store for DesignSystemProvider
113
+ export const useThemeStore = useTheme;
112
114
 
113
115
 
114
116