@umituz/react-native-design-system 2.5.6 → 2.5.8

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.6",
3
+ "version": "2.5.8",
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",
@@ -110,9 +110,10 @@ export const AtomicIcon: React.FC<AtomicIconProps> = React.memo(({
110
110
 
111
111
  // Calculate size
112
112
  const baseSize = customSize ?? size;
113
- const sizeInPixels = typeof baseSize === 'number'
113
+ const iconSizesMap = tokens.iconSizes as Record<string, number>;
114
+ const sizeInPixels: number = typeof baseSize === 'number'
114
115
  ? baseSize * tokens.spacingMultiplier
115
- : (tokens.iconSizes as Record<string, number>)[baseSize] || (tokens.iconSizes as Record<string, number>).md;
116
+ : iconSizesMap[baseSize] ?? iconSizesMap['md'] ?? 24;
116
117
 
117
118
  // Calculate color
118
119
  const iconColor = customColor
@@ -18,7 +18,7 @@ interface AlertBannerProps {
18
18
  }
19
19
 
20
20
  export function AlertBanner({ alert }: AlertBannerProps) {
21
- const dismissAlert = useAlertStore((state) => state.dismissAlert);
21
+ const dismissAlert = useAlertStore((state: { dismissAlert: (id: string) => void }) => state.dismissAlert);
22
22
  const insets = useSafeAreaInsets();
23
23
  const tokens = useAppDesignTokens();
24
24
 
@@ -10,22 +10,22 @@ import { useAlertStore } from './AlertStore';
10
10
  import { AlertToast } from './AlertToast';
11
11
  import { AlertBanner } from './AlertBanner';
12
12
  import { AlertModal } from './AlertModal';
13
- import { AlertMode } from './AlertTypes';
13
+ import { Alert, AlertMode } from './AlertTypes';
14
14
 
15
15
  export const AlertContainer: React.FC = () => {
16
- const alerts = useAlertStore((state) => state.alerts);
16
+ const alerts = useAlertStore((state: { alerts: Alert[] }) => state.alerts);
17
17
  const insets = useSafeAreaInsets();
18
18
  const tokens = useAppDesignTokens();
19
19
 
20
- const toasts = alerts.filter((a) => a.mode === AlertMode.TOAST);
21
- const banners = alerts.filter((a) => a.mode === AlertMode.BANNER);
22
- const modals = alerts.filter((a) => a.mode === AlertMode.MODAL);
20
+ const toasts = alerts.filter((a: Alert) => a.mode === AlertMode.TOAST);
21
+ const banners = alerts.filter((a: Alert) => a.mode === AlertMode.BANNER);
22
+ const modals = alerts.filter((a: Alert) => a.mode === AlertMode.MODAL);
23
23
 
24
24
  return (
25
25
  <View style={styles.container} pointerEvents="box-none">
26
26
  {/* Banners at top */}
27
27
  <View style={[styles.bannerContainer, { paddingTop: insets.top }]}>
28
- {banners.map((alert) => (
28
+ {banners.map((alert: Alert) => (
29
29
  <AlertBanner key={alert.id} alert={alert} />
30
30
  ))}
31
31
  </View>
@@ -38,7 +38,7 @@ export const AlertContainer: React.FC = () => {
38
38
  paddingHorizontal: tokens.spacing.md,
39
39
  }
40
40
  ]}>
41
- {toasts.map((alert) => (
41
+ {toasts.map((alert: Alert) => (
42
42
  <View key={alert.id} style={{ marginBottom: tokens.spacing.sm, width: '100%' }}>
43
43
  <AlertToast alert={alert} />
44
44
  </View>
@@ -46,7 +46,7 @@ export const AlertContainer: React.FC = () => {
46
46
  </View>
47
47
 
48
48
  {/* Modals on top of everything */}
49
- {modals.map((alert) => (
49
+ {modals.map((alert: Alert) => (
50
50
  <AlertModal key={alert.id} alert={alert} />
51
51
  ))}
52
52
  </View>
@@ -14,7 +14,7 @@ interface AlertModalProps {
14
14
  }
15
15
 
16
16
  export const AlertModal: React.FC<AlertModalProps> = ({ alert }) => {
17
- const dismissAlert = useAlertStore((state) => state.dismissAlert);
17
+ const dismissAlert = useAlertStore((state: { dismissAlert: (id: string) => void }) => state.dismissAlert);
18
18
  const tokens = useAppDesignTokens();
19
19
 
20
20
  const handleClose = () => {
@@ -2,21 +2,27 @@
2
2
  * Alert Store
3
3
  */
4
4
 
5
- import { create } from 'zustand';
5
+ import { create, type StoreApi } from 'zustand';
6
6
  import { Alert } from './AlertTypes';
7
7
 
8
8
  interface AlertState {
9
9
  alerts: Alert[];
10
+ }
11
+
12
+ interface AlertActions {
10
13
  addAlert: (alert: Alert) => void;
11
14
  dismissAlert: (id: string) => void;
12
15
  clearAlerts: () => void;
13
16
  }
14
17
 
15
- export const useAlertStore = create<AlertState>((set) => ({
18
+ type AlertStore = AlertState & AlertActions;
19
+ type SetState = StoreApi<AlertStore>['setState'];
20
+
21
+ export const useAlertStore = create<AlertStore>((set: SetState) => ({
16
22
  alerts: [],
17
- addAlert: (alert) => set((state) => ({ alerts: [...state.alerts, alert] })),
18
- dismissAlert: (id) => set((state) => ({
19
- alerts: state.alerts.filter((a) => a.id !== id)
23
+ addAlert: (alert: Alert) => set((state: AlertStore) => ({ alerts: [...state.alerts, alert] })),
24
+ dismissAlert: (id: string) => set((state: AlertStore) => ({
25
+ alerts: state.alerts.filter((a: Alert) => a.id !== id)
20
26
  })),
21
27
  clearAlerts: () => set({ alerts: [] }),
22
28
  }));
@@ -17,7 +17,7 @@ interface AlertToastProps {
17
17
  }
18
18
 
19
19
  export function AlertToast({ alert }: AlertToastProps) {
20
- const dismissAlert = useAlertStore((state) => state.dismissAlert);
20
+ const dismissAlert = useAlertStore((state: { dismissAlert: (id: string) => void }) => state.dismissAlert);
21
21
  const tokens = useAppDesignTokens();
22
22
 
23
23
  const handleDismiss = () => {
@@ -104,7 +104,8 @@ export const useFireworks = (config: FireworksConfig) => {
104
104
 
105
105
  const newParticles: ParticleConfig[] = [];
106
106
  for (let i = 0; i < particleCount; i++) {
107
- const color = colors[Math.floor(Math.random() * colors.length)];
107
+ const colorIndex = Math.floor(Math.random() * colors.length);
108
+ const color = colors[colorIndex] ?? colors[0] ?? '#FFFFFF';
108
109
  newParticles.push(createParticle(centerX, centerY, color));
109
110
  }
110
111
 
@@ -165,9 +165,11 @@ export class AvatarUtils {
165
165
 
166
166
  if (words.length >= 2) {
167
167
  // Full name: First letter of first + first letter of last
168
- const first = words[0][0];
169
- const last = words[words.length - 1][0];
170
- return (first + last).toLocaleUpperCase('tr-TR');
168
+ const firstWord = words[0] ?? '';
169
+ const lastWord = words[words.length - 1] ?? '';
170
+ const first = firstWord[0] ?? '';
171
+ const last = lastWord[0] ?? '';
172
+ return (first + last).toLocaleUpperCase('tr-TR') || '?';
171
173
  } else {
172
174
  // Single word: First 2 letters
173
175
  return trimmed.slice(0, 2).toLocaleUpperCase('tr-TR');
@@ -11,8 +11,8 @@
11
11
  * - Timezone-aware via CalendarService
12
12
  */
13
13
 
14
- import { create } from 'zustand';
15
- import { persist, createJSONStorage } from 'zustand/middleware';
14
+ import { create, type StateCreator } from 'zustand';
15
+ import { persist, createJSONStorage, type PersistOptions } from 'zustand/middleware';
16
16
  import AsyncStorage from '@react-native-async-storage/async-storage';
17
17
  import type { CalendarEvent, CreateCalendarEventRequest, UpdateCalendarEventRequest } from '../../domain/entities/CalendarEvent.entity';
18
18
  import { CalendarService } from '../services/CalendarService';
@@ -14,7 +14,8 @@ export class DateUtilities {
14
14
  * Format date to string (YYYY-MM-DD)
15
15
  */
16
16
  static formatDateToString(date: Date): string {
17
- return date.toISOString().split('T')[0];
17
+ const parts = date.toISOString().split('T');
18
+ return parts[0] ?? '';
18
19
  }
19
20
 
20
21
  /**
@@ -91,7 +92,10 @@ export class DateUtilities {
91
92
  * Parse date from string (YYYY-MM-DD)
92
93
  */
93
94
  static parseDate(dateString: string): Date {
94
- const [year, month, day] = dateString.split('-').map(Number);
95
+ const parts = dateString.split('-').map(Number);
96
+ const year = parts[0] ?? 0;
97
+ const month = parts[1] ?? 1;
98
+ const day = parts[2] ?? 1;
95
99
  return new Date(year, month - 1, day);
96
100
  }
97
101
 
@@ -84,7 +84,7 @@ export const useCalendar = (): UseCalendarReturn => {
84
84
  isLoading,
85
85
  error,
86
86
  actions,
87
- } = useCalendarStore((state) => state);
87
+ } = useCalendarStore((state: ReturnType<typeof useCalendarStore.getState>) => state);
88
88
 
89
89
  // Load events on mount
90
90
  useEffect(() => {
@@ -133,7 +133,7 @@ export const useCalendarNavigation = () => {
133
133
  selectedDate,
134
134
  currentMonth,
135
135
  actions: { setSelectedDate, navigateMonth, goToToday, setCurrentMonth },
136
- } = useCalendarStore((state) => state);
136
+ } = useCalendarStore((state: ReturnType<typeof useCalendarStore.getState>) => state);
137
137
 
138
138
  return {
139
139
  selectedDate,
@@ -163,7 +163,7 @@ export const useCalendarEvents = () => {
163
163
  uncompleteEvent,
164
164
  clearError,
165
165
  },
166
- } = useCalendarStore((state) => state);
166
+ } = useCalendarStore((state: ReturnType<typeof useCalendarStore.getState>) => state);
167
167
 
168
168
  return {
169
169
  events,