@umituz/react-native-design-system 1.1.0 → 1.1.2

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": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "Universal design system for React Native apps - Domain-Driven Design architecture with Material Design 3 components",
5
5
  "main": "src/index.ts",
6
6
  "types": "src/index.ts",
@@ -26,8 +26,7 @@
26
26
  */
27
27
 
28
28
  import { create } from 'zustand';
29
-
30
- export type ThemeMode = 'light' | 'dark';
29
+ import type { ThemeMode } from '../../presentation/tokens/core/ColorPalette';
31
30
 
32
31
  interface GlobalThemeStore {
33
32
  /** Current theme mode */
@@ -47,3 +46,6 @@ export const useDesignSystemTheme = create<GlobalThemeStore>((set) => ({
47
46
  themeMode: 'light',
48
47
  setThemeMode: (mode: ThemeMode) => set({ themeMode: mode }),
49
48
  }));
49
+
50
+ // Re-export ThemeMode for backward compatibility
51
+ export type { ThemeMode };
@@ -7,9 +7,9 @@
7
7
  * Features:
8
8
  * - Platform-specific native pickers (iOS wheel, Android dialog)
9
9
  * - Consistent styling with design tokens
10
- * - Locale-aware date/time formatting (via timezone domain)
10
+ * - Locale-aware date/time formatting (native Date methods)
11
11
  * - Timezone-aware (respects device timezone)
12
- * - Automatic language integration (changes with app language)
12
+ * - Automatic language integration (native locale support)
13
13
  * - Optional label and error states
14
14
  * - Minimum and maximum date constraints
15
15
  * - Disabled state support
@@ -47,7 +47,6 @@ import {
47
47
  } from 'react-native';
48
48
  import DateTimePicker, { DateTimePickerEvent } from '@react-native-community/datetimepicker';
49
49
  import { useSafeAreaInsets } from 'react-native-safe-area-context';
50
- import { useTimezone } from '@domains/timezone';
51
50
  import { useAppDesignTokens } from '../hooks/useAppDesignTokens';
52
51
  import { useResponsive } from '../hooks/useResponsive';
53
52
  import { AtomicIcon, type AtomicIconColor } from './AtomicIcon';
@@ -104,7 +103,6 @@ export const AtomicDatePicker: React.FC<AtomicDatePickerProps> = ({
104
103
  const { height } = useWindowDimensions();
105
104
  const insets = useSafeAreaInsets();
106
105
  const { isTabletDevice } = useResponsive();
107
- const { formatDate: formatDateTz, formatTime } = useTimezone();
108
106
  const [show, setShow] = useState(false);
109
107
 
110
108
  /**
@@ -128,26 +126,35 @@ export const AtomicDatePicker: React.FC<AtomicDatePickerProps> = ({
128
126
 
129
127
  /**
130
128
  * Format date based on mode
131
- * Uses timezone domain for locale-aware and timezone-aware formatting
132
- * Automatically respects user's selected language and device timezone
129
+ * Uses native Date formatting (locale-aware)
133
130
  */
134
131
  const formatDate = (date: Date): string => {
135
132
  if (mode === 'time') {
136
- // Format time only (e.g., "02:30 PM" in English, "14:30" in Turkish)
137
- return formatTime(date);
133
+ // Format time only
134
+ return date.toLocaleTimeString([], {
135
+ hour: '2-digit',
136
+ minute: '2-digit'
137
+ });
138
138
  }
139
139
  if (mode === 'datetime') {
140
- // Format date + time (e.g., "January 15, 2024 02:30 PM")
141
- const dateStr = formatDateTz(date, {
140
+ // Format date + time
141
+ const dateStr = date.toLocaleDateString([], {
142
142
  year: 'numeric',
143
143
  month: 'short',
144
144
  day: 'numeric',
145
145
  });
146
- const timeStr = formatTime(date);
146
+ const timeStr = date.toLocaleTimeString([], {
147
+ hour: '2-digit',
148
+ minute: '2-digit'
149
+ });
147
150
  return `${dateStr} ${timeStr}`;
148
151
  }
149
- // Format date only (e.g., "January 15, 2024" in English, "15 Ocak 2024" in Turkish)
150
- return formatDateTz(date);
152
+ // Format date only
153
+ return date.toLocaleDateString([], {
154
+ year: 'numeric',
155
+ month: 'long',
156
+ day: 'numeric',
157
+ });
151
158
  };
152
159
 
153
160
  /**
@@ -1,29 +1,113 @@
1
1
  /**
2
2
  * AtomicIcon - Design System Icon Component
3
3
  *
4
- * Simple wrapper around Icon domain for backward compatibility.
5
- * All icon functionality is provided by @domains/icons.
6
- *
7
- * @deprecated Use Icon from @domains/icons directly in new code
4
+ * Universal icon component using Lucide icons.
5
+ * Provides semantic color mappings and size presets.
8
6
  */
9
7
 
10
8
  import React from 'react';
11
- import { Icon, type IconProps } from '@domains/icons';
9
+ import * as LucideIcons from 'lucide-react-native';
10
+ import { useAppDesignTokens } from '../hooks/useAppDesignTokens';
12
11
 
13
12
  /**
14
- * AtomicIcon Component (Wrapper)
15
- *
16
- * This is a simple wrapper around Icon from @domains/icons.
17
- * It exists for backward compatibility with existing code.
13
+ * Icon size presets
14
+ */
15
+ export type IconSize = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | 'xxl';
16
+
17
+ /**
18
+ * Semantic color tokens
19
+ */
20
+ export type IconColor =
21
+ | 'primary'
22
+ | 'secondary'
23
+ | 'error'
24
+ | 'warning'
25
+ | 'success'
26
+ | 'info'
27
+ | 'onPrimary'
28
+ | 'onSurface'
29
+ | 'textPrimary'
30
+ | 'textSecondary'
31
+ | 'textDisabled';
32
+
33
+ /**
34
+ * Icon component props
35
+ */
36
+ export interface IconProps {
37
+ /** Icon name from Lucide icon set (PascalCase) */
38
+ name: string;
39
+ /** Semantic color token */
40
+ color?: IconColor;
41
+ /** Size preset */
42
+ size?: IconSize;
43
+ /** Custom size override (pixels) */
44
+ customSize?: number;
45
+ /** Custom color override (hex) */
46
+ customColor?: string;
47
+ }
48
+
49
+ /**
50
+ * Size mapping (pixels)
51
+ */
52
+ const sizeMap: Record<IconSize, number> = {
53
+ xs: 16,
54
+ sm: 20,
55
+ md: 24,
56
+ lg: 28,
57
+ xl: 32,
58
+ xxl: 48,
59
+ };
60
+
61
+ /**
62
+ * AtomicIcon Component
18
63
  *
19
- * For new code, import Icon directly from @domains/icons
64
+ * Universal icon component with theme integration
20
65
  */
21
- export const AtomicIcon: React.FC<IconProps> = (props) => {
22
- return <Icon {...props} />;
66
+ export const AtomicIcon: React.FC<IconProps> = ({
67
+ name,
68
+ color = 'textPrimary',
69
+ size = 'md',
70
+ customSize,
71
+ customColor,
72
+ }) => {
73
+ const tokens = useAppDesignTokens();
74
+
75
+ // Get icon component from Lucide
76
+ const IconComponent = (LucideIcons as any)[name];
77
+
78
+ if (!IconComponent) {
79
+ console.warn(`Icon "${name}" not found in Lucide icon set`);
80
+ return null;
81
+ }
82
+
83
+ // Resolve color from semantic token
84
+ const resolveColor = (): string => {
85
+ if (customColor) return customColor;
86
+
87
+ const colorMap: Record<IconColor, string> = {
88
+ primary: tokens.colors.primary,
89
+ secondary: tokens.colors.secondary,
90
+ error: tokens.colors.error,
91
+ warning: tokens.colors.warning,
92
+ success: tokens.colors.success,
93
+ info: tokens.colors.info,
94
+ onPrimary: tokens.colors.onPrimary,
95
+ onSurface: tokens.colors.onSurface,
96
+ textPrimary: tokens.colors.textPrimary,
97
+ textSecondary: tokens.colors.textSecondary,
98
+ textDisabled: tokens.colors.textDisabled,
99
+ };
100
+
101
+ return colorMap[color];
102
+ };
103
+
104
+ // Resolve size
105
+ const iconSize = customSize || sizeMap[size];
106
+
107
+ return <IconComponent color={resolveColor()} size={iconSize} />;
23
108
  };
24
109
 
25
110
  // Re-export types for backward compatibility
26
- export type { IconProps as AtomicIconProps } from '@domains/icons';
27
- export type { IconSize as AtomicIconSize } from '@domains/icons';
28
- export type { IconColor as AtomicIconColor } from '@domains/icons';
29
- export type { IconName as AtomicIconName } from '@domains/icons';
111
+ export type AtomicIconProps = IconProps;
112
+ export type AtomicIconSize = IconSize;
113
+ export type AtomicIconColor = IconColor;
@@ -1,19 +1,17 @@
1
1
  /**
2
2
  * useAppDesignTokens Hook - Theme-Aware Design Tokens
3
3
  *
4
- * ✅ Accepts optional themeMode parameter
5
- * ✅ Returns tokens for specified theme (light/dark)
6
- * ✅ Apps control theme, package provides tokens
4
+ * ✅ Automatically reads theme from global store
5
+ * ✅ No parameters needed - fully automatic!
6
+ * ✅ Returns tokens for current theme (light/dark)
7
7
  * ✅ Single source of truth
8
8
  *
9
- * @param themeMode - Optional theme mode ('light' | 'dark'), defaults to 'light'
10
- *
11
- * @example Basic usage (light theme)
9
+ * @example Usage (fully automatic theme-aware)
12
10
  * ```typescript
13
11
  * import { useAppDesignTokens } from '@umituz/react-native-design-system';
14
12
  *
15
13
  * const MyComponent = () => {
16
- * const tokens = useAppDesignTokens(); // Uses light theme by default
14
+ * const tokens = useAppDesignTokens(); // Automatically uses current theme!
17
15
  * return (
18
16
  * <View style={{
19
17
  * backgroundColor: tokens.colors.primary,
@@ -25,29 +23,18 @@
25
23
  * };
26
24
  * ```
27
25
  *
28
- * @example Theme-aware usage
29
- * ```typescript
30
- * import { useAppDesignTokens } from '@umituz/react-native-design-system';
31
- * import { useTheme } from '@domains/theme';
32
- *
33
- * const MyComponent = () => {
34
- * const { themeMode } = useTheme(); // Get theme from app's theme system
35
- * const tokens = useAppDesignTokens(themeMode); // Pass theme to hook
36
- *
37
- * return (
38
- * <View style={{ backgroundColor: tokens.colors.background }}>
39
- * <Text style={{ color: tokens.colors.textPrimary }}>
40
- * This text color changes with theme!
41
- * </Text>
42
- * </View>
43
- * );
44
- * };
45
- * ```
26
+ * How it works:
27
+ * - Reads themeMode from global store (useDesignSystemTheme)
28
+ * - App's theme store syncs to global store automatically
29
+ * - All components get correct tokens without prop drilling
30
+ * - Change theme once, everything updates!
46
31
  */
47
32
 
48
33
  import { useMemo } from 'react';
49
- import { createDesignTokens, type DesignTokens, type ThemeMode } from '../tokens/core/TokenFactory';
34
+ import { createDesignTokens, type DesignTokens } from '../tokens/core/TokenFactory';
35
+ import { useDesignSystemTheme } from '../../infrastructure/theme/globalThemeStore';
50
36
 
51
- export const useAppDesignTokens = (themeMode: ThemeMode = 'light'): DesignTokens => {
37
+ export const useAppDesignTokens = (): DesignTokens => {
38
+ const { themeMode } = useDesignSystemTheme();
52
39
  return useMemo(() => createDesignTokens(themeMode), [themeMode]);
53
40
  };
@@ -30,8 +30,6 @@ import { View, ScrollView, StyleSheet, ViewStyle } from 'react-native';
30
30
  import { SafeAreaView, Edge } from 'react-native-safe-area-context';
31
31
  import { useAppDesignTokens } from '../hooks/useAppDesignTokens';
32
32
  import { LoadingState } from '../loading/presentation/components/LoadingState';
33
- import { useDesignSystemTheme } from '../../infrastructure/theme/globalThemeStore';
34
- import type { ThemeMode } from '../tokens/core/TokenFactory';
35
33
 
36
34
  export interface ScreenLayoutProps {
37
35
  /**
@@ -114,12 +112,6 @@ export interface ScreenLayoutProps {
114
112
  */
115
113
  keyboardAvoiding?: boolean;
116
114
 
117
- /**
118
- * Theme mode for design tokens
119
- * If not provided, uses global theme from useDesignSystemTheme()
120
- * Apps should sync their theme with the global store instead of passing this prop
121
- */
122
- themeMode?: ThemeMode;
123
115
  }
124
116
 
125
117
  export const ScreenLayout: React.FC<ScreenLayoutProps> = ({
@@ -137,13 +129,9 @@ export const ScreenLayout: React.FC<ScreenLayoutProps> = ({
137
129
  testID,
138
130
  hideScrollIndicator = false,
139
131
  keyboardAvoiding = false,
140
- themeMode,
141
132
  }) => {
142
- // Use global theme if themeMode prop not provided
143
- const { themeMode: globalTheme } = useDesignSystemTheme();
144
- const effectiveTheme = themeMode ?? globalTheme;
145
-
146
- const tokens = useAppDesignTokens(effectiveTheme);
133
+ // Automatically uses current theme from global store
134
+ const tokens = useAppDesignTokens();
147
135
  const styles = useMemo(() => getStyles(tokens), [tokens]);
148
136
 
149
137
  const bgColor = backgroundColor || tokens.colors.backgroundPrimary;