@umituz/react-native-design-system 2.5.10 → 2.5.12
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.
|
|
3
|
+
"version": "2.5.12",
|
|
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",
|
|
@@ -59,6 +59,7 @@
|
|
|
59
59
|
"@umituz/react-native-filesystem": "*",
|
|
60
60
|
"@umituz/react-native-haptics": "*",
|
|
61
61
|
"@umituz/react-native-localization": "*",
|
|
62
|
+
"@umituz/react-native-storage": "*",
|
|
62
63
|
"@umituz/react-native-uuid": "*",
|
|
63
64
|
"expo-application": ">=5.0.0",
|
|
64
65
|
"expo-clipboard": ">=8.0.0",
|
|
@@ -112,6 +113,7 @@
|
|
|
112
113
|
"@umituz/react-native-filesystem": "^2.1.7",
|
|
113
114
|
"@umituz/react-native-haptics": "^1.0.2",
|
|
114
115
|
"@umituz/react-native-localization": "^3.5.34",
|
|
116
|
+
"@umituz/react-native-storage": "latest",
|
|
115
117
|
"@umituz/react-native-uuid": "*",
|
|
116
118
|
"eslint": "^9.39.2",
|
|
117
119
|
"eslint-plugin-react": "^7.37.5",
|
|
@@ -23,72 +23,77 @@ import { CalendarService } from '../services/CalendarService';
|
|
|
23
23
|
export type CalendarViewMode = 'month' | 'week' | 'day' | 'list';
|
|
24
24
|
|
|
25
25
|
/**
|
|
26
|
-
*
|
|
26
|
+
* Storage key for calendar events
|
|
27
|
+
*/
|
|
28
|
+
const STORAGE_KEY = 'calendar_events';
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Generate unique ID for events
|
|
32
|
+
*/
|
|
33
|
+
const generateId = (): string => {
|
|
34
|
+
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Calendar state (data only)
|
|
27
39
|
*/
|
|
28
40
|
interface CalendarState {
|
|
29
|
-
// State
|
|
30
41
|
events: CalendarEvent[];
|
|
31
42
|
selectedDate: Date;
|
|
32
43
|
currentMonth: Date;
|
|
33
44
|
viewMode: CalendarViewMode;
|
|
34
45
|
isLoading: boolean;
|
|
35
46
|
error: string | null;
|
|
47
|
+
}
|
|
36
48
|
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
49
|
+
/**
|
|
50
|
+
* Calendar actions
|
|
51
|
+
*/
|
|
52
|
+
interface CalendarActions {
|
|
53
|
+
// Event CRUD
|
|
54
|
+
loadEvents: () => Promise<void>;
|
|
55
|
+
addEvent: (request: CreateCalendarEventRequest) => Promise<void>;
|
|
56
|
+
updateEvent: (request: UpdateCalendarEventRequest) => Promise<void>;
|
|
57
|
+
deleteEvent: (id: string) => Promise<void>;
|
|
58
|
+
completeEvent: (id: string) => Promise<void>;
|
|
59
|
+
uncompleteEvent: (id: string) => Promise<void>;
|
|
46
60
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
61
|
+
// Navigation
|
|
62
|
+
setSelectedDate: (date: Date) => void;
|
|
63
|
+
goToToday: () => void;
|
|
64
|
+
navigateMonth: (direction: 'prev' | 'next') => void;
|
|
65
|
+
navigateWeek: (direction: 'prev' | 'next') => void;
|
|
66
|
+
setCurrentMonth: (date: Date) => void;
|
|
53
67
|
|
|
54
|
-
|
|
55
|
-
|
|
68
|
+
// View mode
|
|
69
|
+
setViewMode: (mode: CalendarViewMode) => void;
|
|
56
70
|
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
};
|
|
71
|
+
// Utilities
|
|
72
|
+
getEventsForDate: (date: Date) => CalendarEvent[];
|
|
73
|
+
getEventsForMonth: (year: number, month: number) => CalendarEvent[];
|
|
74
|
+
clearError: () => void;
|
|
75
|
+
clearAllEvents: () => Promise<void>;
|
|
63
76
|
}
|
|
64
77
|
|
|
65
78
|
/**
|
|
66
|
-
*
|
|
67
|
-
*/
|
|
68
|
-
const STORAGE_KEY = 'calendar_events';
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Generate unique ID for events
|
|
79
|
+
* Initial state
|
|
72
80
|
*/
|
|
73
|
-
const
|
|
74
|
-
|
|
81
|
+
const initialState: CalendarState = {
|
|
82
|
+
events: [],
|
|
83
|
+
selectedDate: new Date(),
|
|
84
|
+
currentMonth: new Date(),
|
|
85
|
+
viewMode: 'month',
|
|
86
|
+
isLoading: false,
|
|
87
|
+
error: null,
|
|
75
88
|
};
|
|
76
89
|
|
|
77
90
|
/**
|
|
78
91
|
* Calendar Store
|
|
79
92
|
*/
|
|
80
|
-
export const useCalendarStore = create<CalendarState>()(
|
|
93
|
+
export const useCalendarStore = create<CalendarState & { actions: CalendarActions }>()(
|
|
81
94
|
persist(
|
|
82
95
|
(set, get) => ({
|
|
83
|
-
|
|
84
|
-
events: [],
|
|
85
|
-
selectedDate: new Date(),
|
|
86
|
-
currentMonth: new Date(),
|
|
87
|
-
viewMode: 'month',
|
|
88
|
-
isLoading: false,
|
|
89
|
-
error: null,
|
|
90
|
-
|
|
91
|
-
// Actions
|
|
96
|
+
...initialState,
|
|
92
97
|
actions: {
|
|
93
98
|
/**
|
|
94
99
|
* Load events from storage
|
|
@@ -98,20 +103,21 @@ export const useCalendarStore = create<CalendarState>()(
|
|
|
98
103
|
try {
|
|
99
104
|
const stored = await AsyncStorage.getItem(STORAGE_KEY);
|
|
100
105
|
if (stored) {
|
|
101
|
-
const
|
|
106
|
+
const parsed = JSON.parse(stored) as CalendarEvent[];
|
|
102
107
|
// Restore Date objects
|
|
103
|
-
events.
|
|
104
|
-
event
|
|
105
|
-
|
|
106
|
-
|
|
108
|
+
const events = parsed.map((event) => ({
|
|
109
|
+
...event,
|
|
110
|
+
createdAt: new Date(event.createdAt),
|
|
111
|
+
updatedAt: new Date(event.updatedAt),
|
|
112
|
+
}));
|
|
107
113
|
set({ events, isLoading: false });
|
|
108
114
|
} else {
|
|
109
115
|
set({ isLoading: false });
|
|
110
116
|
}
|
|
111
|
-
} catch
|
|
117
|
+
} catch {
|
|
112
118
|
set({
|
|
113
|
-
error:
|
|
114
|
-
isLoading: false
|
|
119
|
+
error: 'Failed to load events',
|
|
120
|
+
isLoading: false,
|
|
115
121
|
});
|
|
116
122
|
}
|
|
117
123
|
},
|
|
@@ -133,10 +139,10 @@ export const useCalendarStore = create<CalendarState>()(
|
|
|
133
139
|
const events = [...get().events, newEvent];
|
|
134
140
|
await AsyncStorage.setItem(STORAGE_KEY, JSON.stringify(events));
|
|
135
141
|
set({ events, isLoading: false });
|
|
136
|
-
} catch
|
|
142
|
+
} catch {
|
|
137
143
|
set({
|
|
138
|
-
error:
|
|
139
|
-
isLoading: false
|
|
144
|
+
error: 'Failed to add event',
|
|
145
|
+
isLoading: false,
|
|
140
146
|
});
|
|
141
147
|
}
|
|
142
148
|
},
|
|
@@ -147,7 +153,7 @@ export const useCalendarStore = create<CalendarState>()(
|
|
|
147
153
|
updateEvent: async (request: UpdateCalendarEventRequest) => {
|
|
148
154
|
set({ isLoading: true, error: null });
|
|
149
155
|
try {
|
|
150
|
-
const events = get().events.map(event => {
|
|
156
|
+
const events = get().events.map((event) => {
|
|
151
157
|
if (event.id === request.id) {
|
|
152
158
|
return {
|
|
153
159
|
...event,
|
|
@@ -160,10 +166,10 @@ export const useCalendarStore = create<CalendarState>()(
|
|
|
160
166
|
|
|
161
167
|
await AsyncStorage.setItem(STORAGE_KEY, JSON.stringify(events));
|
|
162
168
|
set({ events, isLoading: false });
|
|
163
|
-
} catch
|
|
169
|
+
} catch {
|
|
164
170
|
set({
|
|
165
|
-
error:
|
|
166
|
-
isLoading: false
|
|
171
|
+
error: 'Failed to update event',
|
|
172
|
+
isLoading: false,
|
|
167
173
|
});
|
|
168
174
|
}
|
|
169
175
|
},
|
|
@@ -174,13 +180,13 @@ export const useCalendarStore = create<CalendarState>()(
|
|
|
174
180
|
deleteEvent: async (id: string) => {
|
|
175
181
|
set({ isLoading: true, error: null });
|
|
176
182
|
try {
|
|
177
|
-
const events = get().events.filter(event => event.id !== id);
|
|
183
|
+
const events = get().events.filter((event) => event.id !== id);
|
|
178
184
|
await AsyncStorage.setItem(STORAGE_KEY, JSON.stringify(events));
|
|
179
185
|
set({ events, isLoading: false });
|
|
180
|
-
} catch
|
|
186
|
+
} catch {
|
|
181
187
|
set({
|
|
182
|
-
error:
|
|
183
|
-
isLoading: false
|
|
188
|
+
error: 'Failed to delete event',
|
|
189
|
+
isLoading: false,
|
|
184
190
|
});
|
|
185
191
|
}
|
|
186
192
|
},
|
|
@@ -222,9 +228,10 @@ export const useCalendarStore = create<CalendarState>()(
|
|
|
222
228
|
*/
|
|
223
229
|
navigateMonth: (direction: 'prev' | 'next') => {
|
|
224
230
|
const currentMonth = get().currentMonth;
|
|
225
|
-
const newMonth =
|
|
226
|
-
|
|
227
|
-
|
|
231
|
+
const newMonth =
|
|
232
|
+
direction === 'prev'
|
|
233
|
+
? CalendarService.getPreviousMonth(currentMonth)
|
|
234
|
+
: CalendarService.getNextMonth(currentMonth);
|
|
228
235
|
|
|
229
236
|
set({ currentMonth: newMonth });
|
|
230
237
|
},
|
|
@@ -234,9 +241,10 @@ export const useCalendarStore = create<CalendarState>()(
|
|
|
234
241
|
*/
|
|
235
242
|
navigateWeek: (direction: 'prev' | 'next') => {
|
|
236
243
|
const selectedDate = get().selectedDate;
|
|
237
|
-
const newDate =
|
|
238
|
-
|
|
239
|
-
|
|
244
|
+
const newDate =
|
|
245
|
+
direction === 'prev'
|
|
246
|
+
? CalendarService.getPreviousWeek(selectedDate)
|
|
247
|
+
: CalendarService.getNextWeek(selectedDate);
|
|
240
248
|
|
|
241
249
|
set({ selectedDate: newDate });
|
|
242
250
|
},
|
|
@@ -288,10 +296,10 @@ export const useCalendarStore = create<CalendarState>()(
|
|
|
288
296
|
try {
|
|
289
297
|
await AsyncStorage.removeItem(STORAGE_KEY);
|
|
290
298
|
set({ events: [], isLoading: false });
|
|
291
|
-
} catch
|
|
299
|
+
} catch {
|
|
292
300
|
set({
|
|
293
|
-
error:
|
|
294
|
-
isLoading: false
|
|
301
|
+
error: 'Failed to clear events',
|
|
302
|
+
isLoading: false,
|
|
295
303
|
});
|
|
296
304
|
}
|
|
297
305
|
},
|
|
@@ -300,7 +308,6 @@ export const useCalendarStore = create<CalendarState>()(
|
|
|
300
308
|
{
|
|
301
309
|
name: 'calendar-storage',
|
|
302
310
|
storage: createJSONStorage(() => AsyncStorage),
|
|
303
|
-
// Only persist events, not UI state
|
|
304
311
|
partialize: (state) => ({ events: state.events }),
|
|
305
312
|
}
|
|
306
313
|
)
|
|
@@ -76,6 +76,7 @@ export interface UseCalendarReturn {
|
|
|
76
76
|
* Main calendar hook
|
|
77
77
|
*/
|
|
78
78
|
export const useCalendar = (): UseCalendarReturn => {
|
|
79
|
+
const store = useCalendarStore();
|
|
79
80
|
const {
|
|
80
81
|
events,
|
|
81
82
|
selectedDate,
|
|
@@ -84,7 +85,7 @@ export const useCalendar = (): UseCalendarReturn => {
|
|
|
84
85
|
isLoading,
|
|
85
86
|
error,
|
|
86
87
|
actions,
|
|
87
|
-
} =
|
|
88
|
+
} = store;
|
|
88
89
|
|
|
89
90
|
// Load events on mount
|
|
90
91
|
useEffect(() => {
|
|
@@ -129,11 +130,12 @@ export const useCalendar = (): UseCalendarReturn => {
|
|
|
129
130
|
* Lightweight hook for just navigation actions
|
|
130
131
|
*/
|
|
131
132
|
export const useCalendarNavigation = () => {
|
|
133
|
+
const store = useCalendarStore();
|
|
132
134
|
const {
|
|
133
135
|
selectedDate,
|
|
134
136
|
currentMonth,
|
|
135
137
|
actions: { setSelectedDate, navigateMonth, goToToday, setCurrentMonth },
|
|
136
|
-
} =
|
|
138
|
+
} = store;
|
|
137
139
|
|
|
138
140
|
return {
|
|
139
141
|
selectedDate,
|
|
@@ -150,6 +152,7 @@ export const useCalendarNavigation = () => {
|
|
|
150
152
|
* Lightweight hook for just event operations
|
|
151
153
|
*/
|
|
152
154
|
export const useCalendarEvents = () => {
|
|
155
|
+
const store = useCalendarStore();
|
|
153
156
|
const {
|
|
154
157
|
events,
|
|
155
158
|
isLoading,
|
|
@@ -163,7 +166,7 @@ export const useCalendarEvents = () => {
|
|
|
163
166
|
uncompleteEvent,
|
|
164
167
|
clearError,
|
|
165
168
|
},
|
|
166
|
-
} =
|
|
169
|
+
} = store;
|
|
167
170
|
|
|
168
171
|
return {
|
|
169
172
|
events,
|