@umituz/react-native-design-system 2.9.37 → 2.9.38

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.9.37",
3
+ "version": "2.9.38",
4
4
  "description": "Universal design system for React Native apps - Consolidated package with atoms, molecules, organisms, theme, typography, responsive, safe area, exception, infinite scroll, UUID, image, timezone, offline, onboarding, and loading utilities",
5
5
  "main": "./src/index.ts",
6
6
  "types": "./src/index.ts",
@@ -88,6 +88,16 @@ export interface MediaPickerOptions {
88
88
  quality?: MediaQuality;
89
89
  selectionLimit?: number;
90
90
  base64?: boolean;
91
+ maxFileSizeMB?: number;
92
+ }
93
+
94
+ /**
95
+ * Media validation error types
96
+ */
97
+ export enum MediaValidationError {
98
+ FILE_TOO_LARGE = "FILE_TOO_LARGE",
99
+ INVALID_FORMAT = "INVALID_FORMAT",
100
+ PERMISSION_DENIED = "PERMISSION_DENIED",
91
101
  }
92
102
 
93
103
  /**
@@ -111,6 +121,8 @@ export interface MediaAsset {
111
121
  export interface MediaPickerResult {
112
122
  canceled: boolean;
113
123
  assets?: MediaAsset[];
124
+ error?: MediaValidationError;
125
+ errorMessage?: string;
114
126
  }
115
127
 
116
128
  /**
@@ -128,7 +140,9 @@ export interface CameraOptions {
128
140
  * Media constants
129
141
  */
130
142
  export const MEDIA_CONSTANTS = {
131
- MAX_IMAGE_SIZE: 10 * 1024 * 1024,
143
+ MAX_IMAGE_SIZE_MB: 5,
144
+ MAX_VIDEO_SIZE_MB: 100,
145
+ MAX_IMAGE_SIZE: 5 * 1024 * 1024,
132
146
  MAX_VIDEO_SIZE: 100 * 1024 * 1024,
133
147
  DEFAULT_QUALITY: MediaQuality.HIGH,
134
148
  DEFAULT_FORMAT: ImageFormat.JPEG,
@@ -20,6 +20,7 @@ export {
20
20
  ImageFormat as MediaImageFormat,
21
21
  MediaQuality,
22
22
  MediaLibraryPermission,
23
+ MediaValidationError,
23
24
  MEDIA_CONSTANTS,
24
25
  } from "./domain/entities/Media";
25
26
 
@@ -14,6 +14,7 @@ import type {
14
14
  import {
15
15
  MediaLibraryPermission,
16
16
  MediaType,
17
+ MediaValidationError,
17
18
  MEDIA_CONSTANTS,
18
19
  } from "../../domain/entities/Media";
19
20
  import {
@@ -115,7 +116,11 @@ export class MediaPickerService {
115
116
  const permission =
116
117
  await MediaPickerService.requestMediaLibraryPermission();
117
118
  if (permission === MediaLibraryPermission.DENIED) {
118
- return { canceled: true };
119
+ return {
120
+ canceled: true,
121
+ error: MediaValidationError.PERMISSION_DENIED,
122
+ errorMessage: "Permission to access media library was denied",
123
+ };
119
124
  }
120
125
 
121
126
  const result = await ImagePicker.launchImageLibraryAsync({
@@ -129,7 +134,25 @@ export class MediaPickerService {
129
134
  base64: options?.base64 ?? false,
130
135
  });
131
136
 
132
- return mapPickerResult(result);
137
+ const mappedResult = mapPickerResult(result);
138
+
139
+ // Validate file size if not canceled and has assets
140
+ if (!mappedResult.canceled && mappedResult.assets && mappedResult.assets.length > 0) {
141
+ const maxSizeMB = options?.maxFileSizeMB ?? MEDIA_CONSTANTS.MAX_IMAGE_SIZE_MB;
142
+ const maxSizeBytes = maxSizeMB * 1024 * 1024;
143
+
144
+ for (const asset of mappedResult.assets) {
145
+ if (asset.fileSize && asset.fileSize > maxSizeBytes) {
146
+ return {
147
+ canceled: true,
148
+ error: MediaValidationError.FILE_TOO_LARGE,
149
+ errorMessage: `File size exceeds ${maxSizeMB}MB limit`,
150
+ };
151
+ }
152
+ }
153
+ }
154
+
155
+ return mappedResult;
133
156
  } catch {
134
157
  return { canceled: true };
135
158
  }
@@ -45,6 +45,10 @@ export const useMedia = () => {
45
45
  setError(null);
46
46
  try {
47
47
  const result = await MediaPickerService.pickSingleImage(options);
48
+ // Set error from validation result if present
49
+ if (result.errorMessage) {
50
+ setError(result.errorMessage);
51
+ }
48
52
  return result;
49
53
  } catch (err) {
50
54
  const errorMessage =