@tradly/asset 1.0.19 → 1.0.20

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.
@@ -249,7 +249,7 @@ var MediaApiService = /*#__PURE__*/function () {
249
249
  key: "uploadMedia",
250
250
  value: (function () {
251
251
  var _uploadMedia = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(files, authKey) {
252
- var auth_key, all_files_uri, upload_files, upload_full_files, i, element, file_data, responseFiles, index, path, fileURI, originalFile, fileBody, uri, fileResponse, arrayBuffer, res, errorText, mediaData, _t3, _t4, _t5;
252
+ var auth_key, all_files_uri, upload_files, upload_full_files, i, element, cleanFileName, file_data, responseFiles, index, path, fileURI, originalFile, fileBody, uri, fileResponse, arrayBuffer, res, errorText, errorMsg, mediaData, _t3, _t4, _t5;
253
253
  return _regenerator().w(function (_context4) {
254
254
  while (1) switch (_context4.p = _context4.n) {
255
255
  case 0:
@@ -274,9 +274,11 @@ var MediaApiService = /*#__PURE__*/function () {
274
274
  all_files_uri.push(element.path);
275
275
  } else {
276
276
  // Prepare file data for upload
277
+ // Clean file name: remove spaces (following user's pattern: fileName.replace(/ /g, ""))
278
+ cleanFileName = element.name.replace(/\s/g, "");
277
279
  file_data = {
278
- name: element.name.replace(/\s/g, "-"),
279
- type: element.type
280
+ name: cleanFileName,
281
+ type: element.type || "image/jpeg" // Default MIME type
280
282
  };
281
283
  upload_files.push(file_data);
282
284
  upload_full_files.push(element);
@@ -311,9 +313,6 @@ var MediaApiService = /*#__PURE__*/function () {
311
313
  // For React Native, handle file://, content://, or http:// URIs
312
314
  uri = originalFile.uri;
313
315
  _context4.p = 7;
314
- // For React Native file:// URIs, fetch should work
315
- // Convert file:// URI to blob for S3 upload
316
- console.log("Fetching file from URI:", uri);
317
316
  _context4.n = 8;
318
317
  return fetch(uri);
319
318
  case 8:
@@ -332,7 +331,6 @@ var MediaApiService = /*#__PURE__*/function () {
332
331
  return fileResponse.blob();
333
332
  case 10:
334
333
  fileBody = _context4.v;
335
- console.log("File converted to blob, size:", fileBody.size);
336
334
  _context4.n = 14;
337
335
  break;
338
336
  case 11:
@@ -372,9 +370,6 @@ var MediaApiService = /*#__PURE__*/function () {
372
370
  });
373
371
  throw new Error("Failed to read file from URI: ".concat(uri, ". Error: ").concat(_t3.message, ". Make sure the file URI is accessible."));
374
372
  case 16:
375
- // Upload to S3 using PUT request
376
- console.log("Uploading to S3:", path);
377
- console.log("File type:", upload_files[index].type);
378
373
  _context4.n = 17;
379
374
  return fetch(path, {
380
375
  method: "PUT",
@@ -389,7 +384,6 @@ var MediaApiService = /*#__PURE__*/function () {
389
384
  _context4.n = 18;
390
385
  break;
391
386
  }
392
- console.log("File ".concat(index + 1, " uploaded successfully"));
393
387
  all_files_uri.push(fileURI);
394
388
  _context4.n = 20;
395
389
  break;
@@ -401,7 +395,8 @@ var MediaApiService = /*#__PURE__*/function () {
401
395
  case 19:
402
396
  errorText = _context4.v;
403
397
  console.error("Failed to upload file ".concat(index + 1, ":"), res.status, res.statusText, errorText);
404
- throw new Error("S3 upload failed: ".concat(res.status, " ").concat(res.statusText));
398
+ errorMsg = errorText ? "S3 upload failed: ".concat(res.status, " ").concat(res.statusText, " - ").concat(errorText) : "S3 upload failed: ".concat(res.status, " ").concat(res.statusText);
399
+ throw new Error(errorMsg);
405
400
  case 20:
406
401
  _context4.n = 22;
407
402
  break;
@@ -409,6 +404,8 @@ var MediaApiService = /*#__PURE__*/function () {
409
404
  _context4.p = 21;
410
405
  _t4 = _context4.v;
411
406
  console.error("Error uploading file ".concat(index + 1, ":"), _t4);
407
+ // Re-throw to stop the upload process
408
+ throw _t4;
412
409
  case 22:
413
410
  index++;
414
411
  _context4.n = 5;
@@ -424,7 +421,7 @@ var MediaApiService = /*#__PURE__*/function () {
424
421
  type: 1,
425
422
  parent: 0,
426
423
  url: url,
427
- name: originalFile.name.replace(/\s/g, "-"),
424
+ name: originalFile.name.replace(/\s/g, ""),
428
425
  mime_type: originalFile.type
429
426
  };
430
427
  }); // Save to media API - POST /v1/media with { media: [...] }
@@ -243,7 +243,7 @@ var MediaApiService = /*#__PURE__*/function () {
243
243
  key: "uploadMedia",
244
244
  value: (function () {
245
245
  var _uploadMedia = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4(files, authKey) {
246
- var auth_key, all_files_uri, upload_files, upload_full_files, i, element, file_data, responseFiles, index, path, fileURI, originalFile, fileBody, uri, fileResponse, arrayBuffer, res, errorText, mediaData, _t3, _t4, _t5;
246
+ var auth_key, all_files_uri, upload_files, upload_full_files, i, element, cleanFileName, file_data, responseFiles, index, path, fileURI, originalFile, fileBody, uri, fileResponse, arrayBuffer, res, errorText, errorMsg, mediaData, _t3, _t4, _t5;
247
247
  return _regenerator().w(function (_context4) {
248
248
  while (1) switch (_context4.p = _context4.n) {
249
249
  case 0:
@@ -268,9 +268,11 @@ var MediaApiService = /*#__PURE__*/function () {
268
268
  all_files_uri.push(element.path);
269
269
  } else {
270
270
  // Prepare file data for upload
271
+ // Clean file name: remove spaces (following user's pattern: fileName.replace(/ /g, ""))
272
+ cleanFileName = element.name.replace(/\s/g, "");
271
273
  file_data = {
272
- name: element.name.replace(/\s/g, "-"),
273
- type: element.type
274
+ name: cleanFileName,
275
+ type: element.type || "image/jpeg" // Default MIME type
274
276
  };
275
277
  upload_files.push(file_data);
276
278
  upload_full_files.push(element);
@@ -305,9 +307,6 @@ var MediaApiService = /*#__PURE__*/function () {
305
307
  // For React Native, handle file://, content://, or http:// URIs
306
308
  uri = originalFile.uri;
307
309
  _context4.p = 7;
308
- // For React Native file:// URIs, fetch should work
309
- // Convert file:// URI to blob for S3 upload
310
- console.log("Fetching file from URI:", uri);
311
310
  _context4.n = 8;
312
311
  return fetch(uri);
313
312
  case 8:
@@ -326,7 +325,6 @@ var MediaApiService = /*#__PURE__*/function () {
326
325
  return fileResponse.blob();
327
326
  case 10:
328
327
  fileBody = _context4.v;
329
- console.log("File converted to blob, size:", fileBody.size);
330
328
  _context4.n = 14;
331
329
  break;
332
330
  case 11:
@@ -366,9 +364,6 @@ var MediaApiService = /*#__PURE__*/function () {
366
364
  });
367
365
  throw new Error("Failed to read file from URI: ".concat(uri, ". Error: ").concat(_t3.message, ". Make sure the file URI is accessible."));
368
366
  case 16:
369
- // Upload to S3 using PUT request
370
- console.log("Uploading to S3:", path);
371
- console.log("File type:", upload_files[index].type);
372
367
  _context4.n = 17;
373
368
  return fetch(path, {
374
369
  method: "PUT",
@@ -383,7 +378,6 @@ var MediaApiService = /*#__PURE__*/function () {
383
378
  _context4.n = 18;
384
379
  break;
385
380
  }
386
- console.log("File ".concat(index + 1, " uploaded successfully"));
387
381
  all_files_uri.push(fileURI);
388
382
  _context4.n = 20;
389
383
  break;
@@ -395,7 +389,8 @@ var MediaApiService = /*#__PURE__*/function () {
395
389
  case 19:
396
390
  errorText = _context4.v;
397
391
  console.error("Failed to upload file ".concat(index + 1, ":"), res.status, res.statusText, errorText);
398
- throw new Error("S3 upload failed: ".concat(res.status, " ").concat(res.statusText));
392
+ errorMsg = errorText ? "S3 upload failed: ".concat(res.status, " ").concat(res.statusText, " - ").concat(errorText) : "S3 upload failed: ".concat(res.status, " ").concat(res.statusText);
393
+ throw new Error(errorMsg);
399
394
  case 20:
400
395
  _context4.n = 22;
401
396
  break;
@@ -403,6 +398,8 @@ var MediaApiService = /*#__PURE__*/function () {
403
398
  _context4.p = 21;
404
399
  _t4 = _context4.v;
405
400
  console.error("Error uploading file ".concat(index + 1, ":"), _t4);
401
+ // Re-throw to stop the upload process
402
+ throw _t4;
406
403
  case 22:
407
404
  index++;
408
405
  _context4.n = 5;
@@ -418,7 +415,7 @@ var MediaApiService = /*#__PURE__*/function () {
418
415
  type: 1,
419
416
  parent: 0,
420
417
  url: url,
421
- name: originalFile.name.replace(/\s/g, "-"),
418
+ name: originalFile.name.replace(/\s/g, ""),
422
419
  mime_type: originalFile.type
423
420
  };
424
421
  }); // Save to media API - POST /v1/media with { media: [...] }
@@ -2,6 +2,7 @@ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present,
2
2
  function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
3
3
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
4
4
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
5
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
5
6
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
6
7
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
8
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
@@ -80,6 +81,7 @@ var FileUpload = function FileUpload(_ref) {
80
81
  picker = _ref.picker,
81
82
  pickerOptions = _ref.pickerOptions,
82
83
  icon = _ref.icon,
84
+ icons = _ref.icons,
83
85
  _ref$theme = _ref.theme,
84
86
  theme = _ref$theme === void 0 ? defaultTheme : _ref$theme,
85
87
  containerStyle = _ref.containerStyle,
@@ -96,6 +98,26 @@ var FileUpload = function FileUpload(_ref) {
96
98
  uploadProgress = _useState4[0],
97
99
  setUploadProgress = _useState4[1];
98
100
 
101
+ // Determine which icon to use based on accept type and icons prop
102
+ var getIcon = function getIcon() {
103
+ // If icons object is provided, use it to select based on accept type
104
+ if (icons && _typeof(icons) === "object") {
105
+ var isImage = accept === null || accept === void 0 ? void 0 : accept.includes("image");
106
+ var isVideo = accept === null || accept === void 0 ? void 0 : accept.includes("video");
107
+ if (isImage && icons.image) {
108
+ return icons.image;
109
+ } else if (isVideo && icons.video) {
110
+ return icons.video;
111
+ } else if (icons.default) {
112
+ return icons.default;
113
+ }
114
+ }
115
+
116
+ // Fallback to single icon prop (backward compatibility)
117
+ return icon;
118
+ };
119
+ var selectedIcon = getIcon();
120
+
99
121
  // Convert file picker result to File-like object for apiService
100
122
  var convertToFile = function convertToFile(pickerResult) {
101
123
  // Handle different picker formats:
@@ -116,22 +138,39 @@ var FileUpload = function FileUpload(_ref) {
116
138
  fileName = lastPart ? lastPart.split("?")[0] : null; // Remove query params if any
117
139
  }
118
140
 
119
- // Final fallback
141
+ // Final fallback - generate a meaningful filename
120
142
  if (!fileName) {
121
143
  // Try to guess from mimeType
122
144
  var _mimeType = pickerResult.mimeType || pickerResult.type || "";
145
+ var timestamp = Date.now();
123
146
  if (_mimeType.includes("image")) {
124
- fileName = _mimeType.includes("jpeg") || _mimeType.includes("jpg") ? "image.jpg" : _mimeType.includes("png") ? "image.png" : _mimeType.includes("gif") ? "image.gif" : "image.jpg";
147
+ fileName = _mimeType.includes("jpeg") || _mimeType.includes("jpg") ? "image_".concat(timestamp, ".jpg") : _mimeType.includes("png") ? "image_".concat(timestamp, ".png") : _mimeType.includes("gif") ? "image_".concat(timestamp, ".gif") : _mimeType.includes("webp") ? "image_".concat(timestamp, ".webp") : "image_".concat(timestamp, ".jpg");
125
148
  } else if (_mimeType.includes("video")) {
126
- fileName = "video.mp4";
149
+ fileName = _mimeType.includes("mp4") ? "video_".concat(timestamp, ".mp4") : _mimeType.includes("mov") ? "video_".concat(timestamp, ".mov") : "video_".concat(timestamp, ".mp4");
127
150
  } else {
128
- fileName = "file";
151
+ fileName = "file_".concat(timestamp);
129
152
  }
130
153
  }
131
154
 
132
155
  // Extract MIME type (handle different property names)
133
- var mimeType = pickerResult.mimeType || pickerResult.type || "image/jpeg"; // Default fallback
134
-
156
+ // Use a helper function to determine MIME type from filename if needed
157
+ var getMimeType = function getMimeType(name, fallbackType) {
158
+ var _name$split$pop;
159
+ if (fallbackType) return fallbackType;
160
+ var ext = (_name$split$pop = name.split(".").pop()) === null || _name$split$pop === void 0 ? void 0 : _name$split$pop.toLowerCase();
161
+ var mimeMap = {
162
+ jpg: "image/jpeg",
163
+ jpeg: "image/jpeg",
164
+ png: "image/png",
165
+ gif: "image/gif",
166
+ webp: "image/webp",
167
+ mp4: "video/mp4",
168
+ mov: "video/quicktime",
169
+ mp3: "audio/mpeg"
170
+ };
171
+ return mimeMap[ext] || "image/jpeg";
172
+ };
173
+ var mimeType = pickerResult.mimeType || pickerResult.type || getMimeType(fileName, null);
135
174
  return {
136
175
  uri: uri,
137
176
  name: fileName,
@@ -153,16 +192,7 @@ var FileUpload = function FileUpload(_ref) {
153
192
  setUploadProgress(0);
154
193
  _context.p = 1;
155
194
  // Convert picker results to File-like objects
156
- filesToUpload = fileList.map(convertToFile); // Debug: Log file format for troubleshooting
157
- console.log("Files to upload:", filesToUpload.map(function (f) {
158
- return {
159
- uri: f.uri,
160
- name: f.name,
161
- type: f.type
162
- };
163
- }));
164
-
165
- // Use the API service to upload files
195
+ filesToUpload = fileList.map(convertToFile); // Use the API service to upload files
166
196
  // Note: uploadMedia will need to handle React Native file URIs
167
197
  _context.n = 2;
168
198
  return apiService.uploadMedia(filesToUpload, apiService.authKey);
@@ -297,20 +327,20 @@ var FileUpload = function FileUpload(_ref) {
297
327
  borderRadius: theme.radius.md
298
328
  }, buttonStyle],
299
329
  disabled: isLoading,
300
- children: [icon && /*#__PURE__*/_jsx(View, {
330
+ children: [selectedIcon && /*#__PURE__*/_jsx(View, {
301
331
  style: [styles.iconContainer, {
302
332
  backgroundColor: theme.colors.uploadIconBackground,
303
333
  borderRadius: theme.radius.xl,
304
334
  marginBottom: theme.spacing.sm,
305
335
  padding: theme.spacing.md
306
336
  }, iconContainerStyle],
307
- children: icon
337
+ children: selectedIcon
308
338
  }), /*#__PURE__*/_jsx(Text, {
309
339
  style: [styles.title, {
310
340
  color: theme.colors.uploadText,
311
341
  fontSize: theme.typography.body.fontSize,
312
342
  fontWeight: theme.typography.body.fontWeight,
313
- marginTop: icon ? theme.spacing.sm : 0
343
+ marginTop: selectedIcon ? theme.spacing.sm : 0
314
344
  }, titleStyle],
315
345
  children: title
316
346
  })]
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
- import { View, Text, StyleSheet } from 'react-native';
1
+ import React from "react";
2
+ import { View, Text, StyleSheet } from "react-native";
3
3
  // Note: For better icons, you can use react-native-svg or react-native-vector-icons
4
4
  // This is a simple implementation using Text/View
5
5
  import { jsx as _jsx } from "react/jsx-runtime";
@@ -7,7 +7,7 @@ export var CloseIcon = function CloseIcon(_ref) {
7
7
  var _ref$size = _ref.size,
8
8
  size = _ref$size === void 0 ? 32 : _ref$size,
9
9
  _ref$color = _ref.color,
10
- color = _ref$color === void 0 ? '#000000' : _ref$color;
10
+ color = _ref$color === void 0 ? "#000000" : _ref$color;
11
11
  return /*#__PURE__*/_jsx(View, {
12
12
  style: [styles.closeIcon, {
13
13
  width: size,
@@ -31,21 +31,57 @@ export var CameraIcon = function CameraIcon() {
31
31
  })
32
32
  });
33
33
  };
34
+ export var VideoIcon = function VideoIcon() {
35
+ return /*#__PURE__*/_jsx(View, {
36
+ style: styles.videoIcon,
37
+ children: /*#__PURE__*/_jsx(Text, {
38
+ style: styles.videoIconText,
39
+ children: "\uD83C\uDFA5"
40
+ })
41
+ });
42
+ };
43
+ export var UploadIcon = function UploadIcon() {
44
+ return /*#__PURE__*/_jsx(View, {
45
+ style: styles.uploadIcon,
46
+ children: /*#__PURE__*/_jsx(Text, {
47
+ style: styles.uploadIconText,
48
+ children: "\uD83D\uDCE4"
49
+ })
50
+ });
51
+ };
34
52
  var styles = StyleSheet.create({
35
53
  closeIcon: {
36
- justifyContent: 'center',
37
- alignItems: 'center'
54
+ justifyContent: "center",
55
+ alignItems: "center"
38
56
  },
39
57
  closeIconText: {
40
- fontWeight: 'bold'
58
+ fontWeight: "bold"
41
59
  },
42
60
  cameraIcon: {
43
61
  width: 22,
44
62
  height: 18,
45
- justifyContent: 'center',
46
- alignItems: 'center'
63
+ justifyContent: "center",
64
+ alignItems: "center"
47
65
  },
48
66
  cameraIconText: {
49
67
  fontSize: 18
68
+ },
69
+ videoIcon: {
70
+ width: 22,
71
+ height: 18,
72
+ justifyContent: "center",
73
+ alignItems: "center"
74
+ },
75
+ videoIconText: {
76
+ fontSize: 18
77
+ },
78
+ uploadIcon: {
79
+ width: 22,
80
+ height: 18,
81
+ justifyContent: "center",
82
+ alignItems: "center"
83
+ },
84
+ uploadIconText: {
85
+ fontSize: 18
50
86
  }
51
87
  });
@@ -12,21 +12,27 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
12
12
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
13
13
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
14
14
  function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
15
- import React, { useState, useEffect } from 'react';
16
- import { View, FlatList, Image, TouchableOpacity, StyleSheet, Dimensions } from 'react-native';
17
- import FileUpload from './FileUpload.native';
18
- import ImagesSkeleton from './ImagesSkeleton.native';
19
- import Pagination from './Pagination.native';
20
- import { CameraIcon } from './Icons.native';
21
- import { defaultTheme } from './theme';
15
+ import React, { useState, useEffect } from "react";
16
+ import { View, FlatList, Image, TouchableOpacity, StyleSheet, Dimensions } from "react-native";
17
+ import FileUpload from "./FileUpload.native";
18
+ import ImagesSkeleton from "./ImagesSkeleton.native";
19
+ import Pagination from "./Pagination.native";
20
+ // Icons are now passed via props, no need to import here
21
+ import { defaultTheme } from "./theme";
22
22
  import { jsx as _jsx } from "react/jsx-runtime";
23
- var _Dimensions$get = Dimensions.get('window'),
23
+ var _Dimensions$get = Dimensions.get("window"),
24
24
  SCREEN_WIDTH = _Dimensions$get.width;
25
25
  var NUM_COLUMNS = 3;
26
- var ITEM_MARGIN = 8;
27
- var ITEM_SIZE = (SCREEN_WIDTH - 40 - ITEM_MARGIN * (NUM_COLUMNS - 1) * 2) / NUM_COLUMNS; // 40 = padding, adjust for margins
28
-
29
- var IMAGE_MIME_TYPES = ['image/png', 'image/jpeg', 'image/webp', 'image/svg+xml', 'image/gif', 'image/avif', 'image/x-icon', 'image/vnd.microsoft.icon', 'image/heic', 'image/heif'];
26
+ var ITEM_MARGIN = 4; // Reduced margin for better fit
27
+ // Calculate item size accounting for:
28
+ // - Container padding (md = 12px on each side = 24px total)
29
+ // - Grid padding (2px on each side = 4px total)
30
+ // - Item margins between items (4px * 2 gaps = 8px total)
31
+ var CONTAINER_PADDING = 24; // paddingHorizontal md (12 * 2)
32
+ var GRID_PADDING = 4; // padding 2 on each side (2 * 2)
33
+ var TOTAL_MARGINS = ITEM_MARGIN * (NUM_COLUMNS - 1) * 2; // margins between items (4px * 2 gaps = 8px)
34
+ var ITEM_SIZE = (SCREEN_WIDTH - CONTAINER_PADDING - GRID_PADDING - TOTAL_MARGINS) / NUM_COLUMNS;
35
+ var IMAGE_MIME_TYPES = ["image/png", "image/jpeg", "image/webp", "image/svg+xml", "image/gif", "image/avif", "image/x-icon", "image/vnd.microsoft.icon", "image/heic", "image/heif"];
30
36
  var ImagesGallery = function ImagesGallery(_ref) {
31
37
  var update_data = _ref.update_data,
32
38
  closePopup = _ref.closePopup,
@@ -34,6 +40,7 @@ var ImagesGallery = function ImagesGallery(_ref) {
34
40
  onError = _ref.onError,
35
41
  picker = _ref.picker,
36
42
  pickerOptions = _ref.pickerOptions,
43
+ icons = _ref.icons,
37
44
  _ref$theme = _ref.theme,
38
45
  theme = _ref$theme === void 0 ? defaultTheme : _ref$theme,
39
46
  containerStyle = _ref.containerStyle,
@@ -96,7 +103,7 @@ var ImagesGallery = function ImagesGallery(_ref) {
96
103
  case 3:
97
104
  _context.p = 3;
98
105
  _t = _context.v;
99
- console.error('Error loading media:', _t);
106
+ console.error("Error loading media:", _t);
100
107
  if (onError) {
101
108
  onError(_t);
102
109
  }
@@ -135,13 +142,13 @@ var ImagesGallery = function ImagesGallery(_ref) {
135
142
  onUploadError: onError,
136
143
  picker: picker,
137
144
  pickerOptions: pickerOptions,
138
- theme: theme,
139
- icon: /*#__PURE__*/_jsx(CameraIcon, {})
145
+ icons: icons,
146
+ theme: theme
140
147
  })
141
148
  });
142
149
  }
143
150
  var image = images[index - 1];
144
- var imageUrl = typeof image === 'string' ? image : image.url;
151
+ var imageUrl = typeof image === "string" ? image : image.url;
145
152
  var imageKey = image.id || image.url || index;
146
153
  return /*#__PURE__*/_jsx(TouchableOpacity, {
147
154
  onPress: function onPress() {
@@ -163,7 +170,7 @@ var ImagesGallery = function ImagesGallery(_ref) {
163
170
  });
164
171
  };
165
172
  var data = isLoading ? [] : [{
166
- type: 'upload'
173
+ type: "upload"
167
174
  }].concat(_toConsumableArray(images));
168
175
  return /*#__PURE__*/_jsx(View, {
169
176
  style: [styles.container, containerStyle],
@@ -171,7 +178,7 @@ var ImagesGallery = function ImagesGallery(_ref) {
171
178
  data: data,
172
179
  renderItem: renderItem,
173
180
  keyExtractor: function keyExtractor(item, index) {
174
- if (index === 0) return 'upload';
181
+ if (index === 0) return "upload";
175
182
  var image = images[index - 1];
176
183
  return image.id || image.url || "image-".concat(index);
177
184
  },
@@ -202,16 +209,16 @@ var styles = StyleSheet.create({
202
209
  flex: 1
203
210
  },
204
211
  grid: {
205
- padding: 4
212
+ padding: 2 // Reduced padding for better fit
206
213
  },
207
214
  uploadContainer: {
208
215
  margin: ITEM_MARGIN,
209
- overflow: 'hidden'
216
+ overflow: "hidden"
210
217
  },
211
218
  imageItem: {
212
219
  margin: ITEM_MARGIN,
213
220
  borderRadius: 8,
214
- overflow: 'hidden',
221
+ overflow: "hidden",
215
222
  shadowOffset: {
216
223
  width: 0,
217
224
  height: 2
@@ -221,8 +228,8 @@ var styles = StyleSheet.create({
221
228
  elevation: 5
222
229
  },
223
230
  image: {
224
- width: '100%',
225
- height: '100%'
231
+ width: "100%",
232
+ height: "100%"
226
233
  },
227
234
  paginationContainer: {
228
235
  // Styles applied via theme
@@ -25,6 +25,7 @@ var MediaPopup = function MediaPopup(_ref) {
25
25
  title = _ref$title === void 0 ? "Media Gallery" : _ref$title,
26
26
  picker = _ref.picker,
27
27
  pickerOptions = _ref.pickerOptions,
28
+ icons = _ref.icons,
28
29
  theme = _ref.theme,
29
30
  overlayStyle = _ref.overlayStyle,
30
31
  containerStyle = _ref.containerStyle,
@@ -88,7 +89,7 @@ var MediaPopup = function MediaPopup(_ref) {
88
89
  maxHeight: SCREEN_HEIGHT * sheetHeight,
89
90
  paddingTop: currentTheme.spacing.sm,
90
91
  paddingBottom: currentTheme.spacing.xl,
91
- paddingHorizontal: currentTheme.spacing.xl
92
+ paddingHorizontal: currentTheme.spacing.md // Reduced from xl to md for better fit
92
93
  }, containerStyle, {
93
94
  transform: [{
94
95
  translateY: slideAnim
@@ -129,6 +130,7 @@ var MediaPopup = function MediaPopup(_ref) {
129
130
  onError: onError,
130
131
  picker: picker,
131
132
  pickerOptions: pickerOptions,
133
+ icons: icons,
132
134
  theme: currentTheme
133
135
  })]
134
136
  })
@@ -20,6 +20,7 @@ var MediaTab = function MediaTab(_ref) {
20
20
  onError = _ref.onError,
21
21
  picker = _ref.picker,
22
22
  pickerOptions = _ref.pickerOptions,
23
+ icons = _ref.icons,
23
24
  _ref$theme = _ref.theme,
24
25
  theme = _ref$theme === void 0 ? defaultTheme : _ref$theme,
25
26
  containerStyle = _ref.containerStyle,
@@ -66,6 +67,7 @@ var MediaTab = function MediaTab(_ref) {
66
67
  onError: onError,
67
68
  picker: picker,
68
69
  pickerOptions: pickerOptions,
70
+ icons: icons,
69
71
  theme: theme
70
72
  });
71
73
  }
@@ -79,6 +81,7 @@ var MediaTab = function MediaTab(_ref) {
79
81
  onError: onError,
80
82
  picker: picker,
81
83
  pickerOptions: pickerOptions,
84
+ icons: icons,
82
85
  theme: theme
83
86
  });
84
87
  }
@@ -93,6 +96,7 @@ var MediaTab = function MediaTab(_ref) {
93
96
  onError: onError,
94
97
  picker: picker,
95
98
  pickerOptions: pickerOptions,
99
+ icons: icons,
96
100
  theme: theme
97
101
  });
98
102
  }
@@ -17,7 +17,7 @@ import { View, FlatList, TouchableOpacity, StyleSheet, Dimensions, Text } from '
17
17
  import FileUpload from './FileUpload.native';
18
18
  import ImagesSkeleton from './ImagesSkeleton.native';
19
19
  import Pagination from './Pagination.native';
20
- import { CameraIcon } from './Icons.native';
20
+ // Icons are now passed via props, no need to import here
21
21
  import { defaultTheme } from './theme';
22
22
  // Note: You'll need to install react-native-video for video playback
23
23
  // import Video from 'react-native-video'
@@ -25,8 +25,15 @@ import { jsx as _jsx } from "react/jsx-runtime";
25
25
  var _Dimensions$get = Dimensions.get('window'),
26
26
  SCREEN_WIDTH = _Dimensions$get.width;
27
27
  var NUM_COLUMNS = 3;
28
- var ITEM_MARGIN = 8;
29
- var ITEM_SIZE = (SCREEN_WIDTH - 40 - ITEM_MARGIN * (NUM_COLUMNS - 1) * 2) / NUM_COLUMNS;
28
+ var ITEM_MARGIN = 4; // Reduced margin for better fit
29
+ // Calculate item size accounting for:
30
+ // - Container padding (md = 12px on each side = 24px total)
31
+ // - Grid padding (2px on each side = 4px total)
32
+ // - Item margins between items (4px * 2 gaps = 8px total)
33
+ var CONTAINER_PADDING = 24; // paddingHorizontal md (12 * 2)
34
+ var GRID_PADDING = 4; // padding 2 on each side (2 * 2)
35
+ var TOTAL_MARGINS = ITEM_MARGIN * (NUM_COLUMNS - 1) * 2; // margins between items (4px * 2 gaps = 8px)
36
+ var ITEM_SIZE = (SCREEN_WIDTH - CONTAINER_PADDING - GRID_PADDING - TOTAL_MARGINS) / NUM_COLUMNS;
30
37
  var VIDEO_MIME_TYPES = ['video/mp4', 'video/quicktime', 'video/x-ms-wmv', 'video/h265', 'video/hevc', 'video/webm'];
31
38
  var VideosGallery = function VideosGallery(_ref) {
32
39
  var update_data = _ref.update_data,
@@ -35,6 +42,7 @@ var VideosGallery = function VideosGallery(_ref) {
35
42
  onError = _ref.onError,
36
43
  picker = _ref.picker,
37
44
  pickerOptions = _ref.pickerOptions,
45
+ icons = _ref.icons,
38
46
  _ref$theme = _ref.theme,
39
47
  theme = _ref$theme === void 0 ? defaultTheme : _ref$theme,
40
48
  containerStyle = _ref.containerStyle,
@@ -136,8 +144,8 @@ var VideosGallery = function VideosGallery(_ref) {
136
144
  onUploadError: onError,
137
145
  picker: picker,
138
146
  pickerOptions: pickerOptions,
139
- theme: theme,
140
- icon: /*#__PURE__*/_jsx(CameraIcon, {})
147
+ icons: icons,
148
+ theme: theme
141
149
  })
142
150
  });
143
151
  }
@@ -201,7 +209,7 @@ var styles = StyleSheet.create({
201
209
  flex: 1
202
210
  },
203
211
  grid: {
204
- padding: 4
212
+ padding: 2 // Reduced padding for better fit
205
213
  },
206
214
  uploadContainer: {
207
215
  margin: ITEM_MARGIN
@@ -1,6 +1,5 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
@@ -15,6 +14,7 @@ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present,
15
14
  function _regeneratorDefine2(e, r, n, t) { var i = Object.defineProperty; try { i({}, "", {}); } catch (e) { i = 0; } _regeneratorDefine2 = function _regeneratorDefine(e, r, n, t) { function o(r, n) { _regeneratorDefine2(e, r, function (e) { return this._invoke(r, n, e); }); } r ? i ? i(e, r, { value: n, enumerable: !t, configurable: !t, writable: !t }) : e[r] = n : (o("next", 0), o("throw", 1), o("return", 2)); }, _regeneratorDefine2(e, r, n, t); }
16
15
  function asyncGeneratorStep(n, t, e, r, o, a, c) { try { var i = n[a](c), u = i.value; } catch (n) { return void e(n); } i.done ? t(u) : Promise.resolve(u).then(r, o); }
17
16
  function _asyncToGenerator(n) { return function () { var t = this, e = arguments; return new Promise(function (r, o) { var a = n.apply(t, e); function _next(n) { asyncGeneratorStep(a, r, o, _next, _throw, "next", n); } function _throw(n) { asyncGeneratorStep(a, r, o, _next, _throw, "throw", n); } _next(void 0); }); }; }
17
+ function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
18
18
  function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
19
19
  function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
20
20
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
@@ -86,6 +86,7 @@ var FileUpload = function FileUpload(_ref) {
86
86
  picker = _ref.picker,
87
87
  pickerOptions = _ref.pickerOptions,
88
88
  icon = _ref.icon,
89
+ icons = _ref.icons,
89
90
  _ref$theme = _ref.theme,
90
91
  theme = _ref$theme === void 0 ? _theme.defaultTheme : _ref$theme,
91
92
  containerStyle = _ref.containerStyle,
@@ -102,6 +103,26 @@ var FileUpload = function FileUpload(_ref) {
102
103
  uploadProgress = _useState4[0],
103
104
  setUploadProgress = _useState4[1];
104
105
 
106
+ // Determine which icon to use based on accept type and icons prop
107
+ var getIcon = function getIcon() {
108
+ // If icons object is provided, use it to select based on accept type
109
+ if (icons && _typeof(icons) === "object") {
110
+ var isImage = accept === null || accept === void 0 ? void 0 : accept.includes("image");
111
+ var isVideo = accept === null || accept === void 0 ? void 0 : accept.includes("video");
112
+ if (isImage && icons.image) {
113
+ return icons.image;
114
+ } else if (isVideo && icons.video) {
115
+ return icons.video;
116
+ } else if (icons.default) {
117
+ return icons.default;
118
+ }
119
+ }
120
+
121
+ // Fallback to single icon prop (backward compatibility)
122
+ return icon;
123
+ };
124
+ var selectedIcon = getIcon();
125
+
105
126
  // Convert file picker result to File-like object for apiService
106
127
  var convertToFile = function convertToFile(pickerResult) {
107
128
  // Handle different picker formats:
@@ -122,22 +143,39 @@ var FileUpload = function FileUpload(_ref) {
122
143
  fileName = lastPart ? lastPart.split("?")[0] : null; // Remove query params if any
123
144
  }
124
145
 
125
- // Final fallback
146
+ // Final fallback - generate a meaningful filename
126
147
  if (!fileName) {
127
148
  // Try to guess from mimeType
128
149
  var _mimeType = pickerResult.mimeType || pickerResult.type || "";
150
+ var timestamp = Date.now();
129
151
  if (_mimeType.includes("image")) {
130
- fileName = _mimeType.includes("jpeg") || _mimeType.includes("jpg") ? "image.jpg" : _mimeType.includes("png") ? "image.png" : _mimeType.includes("gif") ? "image.gif" : "image.jpg";
152
+ fileName = _mimeType.includes("jpeg") || _mimeType.includes("jpg") ? "image_".concat(timestamp, ".jpg") : _mimeType.includes("png") ? "image_".concat(timestamp, ".png") : _mimeType.includes("gif") ? "image_".concat(timestamp, ".gif") : _mimeType.includes("webp") ? "image_".concat(timestamp, ".webp") : "image_".concat(timestamp, ".jpg");
131
153
  } else if (_mimeType.includes("video")) {
132
- fileName = "video.mp4";
154
+ fileName = _mimeType.includes("mp4") ? "video_".concat(timestamp, ".mp4") : _mimeType.includes("mov") ? "video_".concat(timestamp, ".mov") : "video_".concat(timestamp, ".mp4");
133
155
  } else {
134
- fileName = "file";
156
+ fileName = "file_".concat(timestamp);
135
157
  }
136
158
  }
137
159
 
138
160
  // Extract MIME type (handle different property names)
139
- var mimeType = pickerResult.mimeType || pickerResult.type || "image/jpeg"; // Default fallback
140
-
161
+ // Use a helper function to determine MIME type from filename if needed
162
+ var getMimeType = function getMimeType(name, fallbackType) {
163
+ var _name$split$pop;
164
+ if (fallbackType) return fallbackType;
165
+ var ext = (_name$split$pop = name.split(".").pop()) === null || _name$split$pop === void 0 ? void 0 : _name$split$pop.toLowerCase();
166
+ var mimeMap = {
167
+ jpg: "image/jpeg",
168
+ jpeg: "image/jpeg",
169
+ png: "image/png",
170
+ gif: "image/gif",
171
+ webp: "image/webp",
172
+ mp4: "video/mp4",
173
+ mov: "video/quicktime",
174
+ mp3: "audio/mpeg"
175
+ };
176
+ return mimeMap[ext] || "image/jpeg";
177
+ };
178
+ var mimeType = pickerResult.mimeType || pickerResult.type || getMimeType(fileName, null);
141
179
  return {
142
180
  uri: uri,
143
181
  name: fileName,
@@ -159,16 +197,7 @@ var FileUpload = function FileUpload(_ref) {
159
197
  setUploadProgress(0);
160
198
  _context.p = 1;
161
199
  // Convert picker results to File-like objects
162
- filesToUpload = fileList.map(convertToFile); // Debug: Log file format for troubleshooting
163
- console.log("Files to upload:", filesToUpload.map(function (f) {
164
- return {
165
- uri: f.uri,
166
- name: f.name,
167
- type: f.type
168
- };
169
- }));
170
-
171
- // Use the API service to upload files
200
+ filesToUpload = fileList.map(convertToFile); // Use the API service to upload files
172
201
  // Note: uploadMedia will need to handle React Native file URIs
173
202
  _context.n = 2;
174
203
  return apiService.uploadMedia(filesToUpload, apiService.authKey);
@@ -303,20 +332,20 @@ var FileUpload = function FileUpload(_ref) {
303
332
  borderRadius: theme.radius.md
304
333
  }, buttonStyle],
305
334
  disabled: isLoading,
306
- children: [icon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
335
+ children: [selectedIcon && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
307
336
  style: [styles.iconContainer, {
308
337
  backgroundColor: theme.colors.uploadIconBackground,
309
338
  borderRadius: theme.radius.xl,
310
339
  marginBottom: theme.spacing.sm,
311
340
  padding: theme.spacing.md
312
341
  }, iconContainerStyle],
313
- children: icon
342
+ children: selectedIcon
314
343
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
315
344
  style: [styles.title, {
316
345
  color: theme.colors.uploadText,
317
346
  fontSize: theme.typography.body.fontSize,
318
347
  fontWeight: theme.typography.body.fontWeight,
319
- marginTop: icon ? theme.spacing.sm : 0
348
+ marginTop: selectedIcon ? theme.spacing.sm : 0
320
349
  }, titleStyle],
321
350
  children: title
322
351
  })]
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.CloseIcon = exports.CameraIcon = void 0;
6
+ exports.VideoIcon = exports.UploadIcon = exports.CloseIcon = exports.CameraIcon = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _reactNative = require("react-native");
9
9
  var _jsxRuntime = require("react/jsx-runtime");
@@ -15,7 +15,7 @@ var CloseIcon = exports.CloseIcon = function CloseIcon(_ref) {
15
15
  var _ref$size = _ref.size,
16
16
  size = _ref$size === void 0 ? 32 : _ref$size,
17
17
  _ref$color = _ref.color,
18
- color = _ref$color === void 0 ? '#000000' : _ref$color;
18
+ color = _ref$color === void 0 ? "#000000" : _ref$color;
19
19
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
20
20
  style: [styles.closeIcon, {
21
21
  width: size,
@@ -39,21 +39,57 @@ var CameraIcon = exports.CameraIcon = function CameraIcon() {
39
39
  })
40
40
  });
41
41
  };
42
+ var VideoIcon = exports.VideoIcon = function VideoIcon() {
43
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
44
+ style: styles.videoIcon,
45
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
46
+ style: styles.videoIconText,
47
+ children: "\uD83C\uDFA5"
48
+ })
49
+ });
50
+ };
51
+ var UploadIcon = exports.UploadIcon = function UploadIcon() {
52
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
53
+ style: styles.uploadIcon,
54
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
55
+ style: styles.uploadIconText,
56
+ children: "\uD83D\uDCE4"
57
+ })
58
+ });
59
+ };
42
60
  var styles = _reactNative.StyleSheet.create({
43
61
  closeIcon: {
44
- justifyContent: 'center',
45
- alignItems: 'center'
62
+ justifyContent: "center",
63
+ alignItems: "center"
46
64
  },
47
65
  closeIconText: {
48
- fontWeight: 'bold'
66
+ fontWeight: "bold"
49
67
  },
50
68
  cameraIcon: {
51
69
  width: 22,
52
70
  height: 18,
53
- justifyContent: 'center',
54
- alignItems: 'center'
71
+ justifyContent: "center",
72
+ alignItems: "center"
55
73
  },
56
74
  cameraIconText: {
57
75
  fontSize: 18
76
+ },
77
+ videoIcon: {
78
+ width: 22,
79
+ height: 18,
80
+ justifyContent: "center",
81
+ alignItems: "center"
82
+ },
83
+ videoIconText: {
84
+ fontSize: 18
85
+ },
86
+ uploadIcon: {
87
+ width: 22,
88
+ height: 18,
89
+ justifyContent: "center",
90
+ alignItems: "center"
91
+ },
92
+ uploadIconText: {
93
+ fontSize: 18
58
94
  }
59
95
  });
@@ -10,7 +10,6 @@ var _reactNative = require("react-native");
10
10
  var _FileUpload = _interopRequireDefault(require("./FileUpload.native"));
11
11
  var _ImagesSkeleton = _interopRequireDefault(require("./ImagesSkeleton.native"));
12
12
  var _Pagination = _interopRequireDefault(require("./Pagination.native"));
13
- var _Icons = require("./Icons.native");
14
13
  var _theme = require("./theme");
15
14
  var _jsxRuntime = require("react/jsx-runtime");
16
15
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -28,14 +27,20 @@ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructur
28
27
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
29
28
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
30
29
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
31
- function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
32
- var _Dimensions$get = _reactNative.Dimensions.get('window'),
30
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } // Icons are now passed via props, no need to import here
31
+ var _Dimensions$get = _reactNative.Dimensions.get("window"),
33
32
  SCREEN_WIDTH = _Dimensions$get.width;
34
33
  var NUM_COLUMNS = 3;
35
- var ITEM_MARGIN = 8;
36
- var ITEM_SIZE = (SCREEN_WIDTH - 40 - ITEM_MARGIN * (NUM_COLUMNS - 1) * 2) / NUM_COLUMNS; // 40 = padding, adjust for margins
37
-
38
- var IMAGE_MIME_TYPES = ['image/png', 'image/jpeg', 'image/webp', 'image/svg+xml', 'image/gif', 'image/avif', 'image/x-icon', 'image/vnd.microsoft.icon', 'image/heic', 'image/heif'];
34
+ var ITEM_MARGIN = 4; // Reduced margin for better fit
35
+ // Calculate item size accounting for:
36
+ // - Container padding (md = 12px on each side = 24px total)
37
+ // - Grid padding (2px on each side = 4px total)
38
+ // - Item margins between items (4px * 2 gaps = 8px total)
39
+ var CONTAINER_PADDING = 24; // paddingHorizontal md (12 * 2)
40
+ var GRID_PADDING = 4; // padding 2 on each side (2 * 2)
41
+ var TOTAL_MARGINS = ITEM_MARGIN * (NUM_COLUMNS - 1) * 2; // margins between items (4px * 2 gaps = 8px)
42
+ var ITEM_SIZE = (SCREEN_WIDTH - CONTAINER_PADDING - GRID_PADDING - TOTAL_MARGINS) / NUM_COLUMNS;
43
+ var IMAGE_MIME_TYPES = ["image/png", "image/jpeg", "image/webp", "image/svg+xml", "image/gif", "image/avif", "image/x-icon", "image/vnd.microsoft.icon", "image/heic", "image/heif"];
39
44
  var ImagesGallery = function ImagesGallery(_ref) {
40
45
  var update_data = _ref.update_data,
41
46
  closePopup = _ref.closePopup,
@@ -43,6 +48,7 @@ var ImagesGallery = function ImagesGallery(_ref) {
43
48
  onError = _ref.onError,
44
49
  picker = _ref.picker,
45
50
  pickerOptions = _ref.pickerOptions,
51
+ icons = _ref.icons,
46
52
  _ref$theme = _ref.theme,
47
53
  theme = _ref$theme === void 0 ? _theme.defaultTheme : _ref$theme,
48
54
  containerStyle = _ref.containerStyle,
@@ -105,7 +111,7 @@ var ImagesGallery = function ImagesGallery(_ref) {
105
111
  case 3:
106
112
  _context.p = 3;
107
113
  _t = _context.v;
108
- console.error('Error loading media:', _t);
114
+ console.error("Error loading media:", _t);
109
115
  if (onError) {
110
116
  onError(_t);
111
117
  }
@@ -144,13 +150,13 @@ var ImagesGallery = function ImagesGallery(_ref) {
144
150
  onUploadError: onError,
145
151
  picker: picker,
146
152
  pickerOptions: pickerOptions,
147
- theme: theme,
148
- icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icons.CameraIcon, {})
153
+ icons: icons,
154
+ theme: theme
149
155
  })
150
156
  });
151
157
  }
152
158
  var image = images[index - 1];
153
- var imageUrl = typeof image === 'string' ? image : image.url;
159
+ var imageUrl = typeof image === "string" ? image : image.url;
154
160
  var imageKey = image.id || image.url || index;
155
161
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
156
162
  onPress: function onPress() {
@@ -172,7 +178,7 @@ var ImagesGallery = function ImagesGallery(_ref) {
172
178
  });
173
179
  };
174
180
  var data = isLoading ? [] : [{
175
- type: 'upload'
181
+ type: "upload"
176
182
  }].concat(_toConsumableArray(images));
177
183
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
178
184
  style: [styles.container, containerStyle],
@@ -180,7 +186,7 @@ var ImagesGallery = function ImagesGallery(_ref) {
180
186
  data: data,
181
187
  renderItem: renderItem,
182
188
  keyExtractor: function keyExtractor(item, index) {
183
- if (index === 0) return 'upload';
189
+ if (index === 0) return "upload";
184
190
  var image = images[index - 1];
185
191
  return image.id || image.url || "image-".concat(index);
186
192
  },
@@ -211,16 +217,16 @@ var styles = _reactNative.StyleSheet.create({
211
217
  flex: 1
212
218
  },
213
219
  grid: {
214
- padding: 4
220
+ padding: 2 // Reduced padding for better fit
215
221
  },
216
222
  uploadContainer: {
217
223
  margin: ITEM_MARGIN,
218
- overflow: 'hidden'
224
+ overflow: "hidden"
219
225
  },
220
226
  imageItem: {
221
227
  margin: ITEM_MARGIN,
222
228
  borderRadius: 8,
223
- overflow: 'hidden',
229
+ overflow: "hidden",
224
230
  shadowOffset: {
225
231
  width: 0,
226
232
  height: 2
@@ -230,8 +236,8 @@ var styles = _reactNative.StyleSheet.create({
230
236
  elevation: 5
231
237
  },
232
238
  image: {
233
- width: '100%',
234
- height: '100%'
239
+ width: "100%",
240
+ height: "100%"
235
241
  },
236
242
  paginationContainer: {
237
243
  // Styles applied via theme
@@ -32,6 +32,7 @@ var MediaPopup = function MediaPopup(_ref) {
32
32
  title = _ref$title === void 0 ? "Media Gallery" : _ref$title,
33
33
  picker = _ref.picker,
34
34
  pickerOptions = _ref.pickerOptions,
35
+ icons = _ref.icons,
35
36
  theme = _ref.theme,
36
37
  overlayStyle = _ref.overlayStyle,
37
38
  containerStyle = _ref.containerStyle,
@@ -95,7 +96,7 @@ var MediaPopup = function MediaPopup(_ref) {
95
96
  maxHeight: SCREEN_HEIGHT * sheetHeight,
96
97
  paddingTop: currentTheme.spacing.sm,
97
98
  paddingBottom: currentTheme.spacing.xl,
98
- paddingHorizontal: currentTheme.spacing.xl
99
+ paddingHorizontal: currentTheme.spacing.md // Reduced from xl to md for better fit
99
100
  }, containerStyle, {
100
101
  transform: [{
101
102
  translateY: slideAnim
@@ -136,6 +137,7 @@ var MediaPopup = function MediaPopup(_ref) {
136
137
  onError: onError,
137
138
  picker: picker,
138
139
  pickerOptions: pickerOptions,
140
+ icons: icons,
139
141
  theme: currentTheme
140
142
  })]
141
143
  })
@@ -29,6 +29,7 @@ var MediaTab = function MediaTab(_ref) {
29
29
  onError = _ref.onError,
30
30
  picker = _ref.picker,
31
31
  pickerOptions = _ref.pickerOptions,
32
+ icons = _ref.icons,
32
33
  _ref$theme = _ref.theme,
33
34
  theme = _ref$theme === void 0 ? _theme.defaultTheme : _ref$theme,
34
35
  containerStyle = _ref.containerStyle,
@@ -75,6 +76,7 @@ var MediaTab = function MediaTab(_ref) {
75
76
  onError: onError,
76
77
  picker: picker,
77
78
  pickerOptions: pickerOptions,
79
+ icons: icons,
78
80
  theme: theme
79
81
  });
80
82
  }
@@ -88,6 +90,7 @@ var MediaTab = function MediaTab(_ref) {
88
90
  onError: onError,
89
91
  picker: picker,
90
92
  pickerOptions: pickerOptions,
93
+ icons: icons,
91
94
  theme: theme
92
95
  });
93
96
  }
@@ -102,6 +105,7 @@ var MediaTab = function MediaTab(_ref) {
102
105
  onError: onError,
103
106
  picker: picker,
104
107
  pickerOptions: pickerOptions,
108
+ icons: icons,
105
109
  theme: theme
106
110
  });
107
111
  }
@@ -10,7 +10,6 @@ var _reactNative = require("react-native");
10
10
  var _FileUpload = _interopRequireDefault(require("./FileUpload.native"));
11
11
  var _ImagesSkeleton = _interopRequireDefault(require("./ImagesSkeleton.native"));
12
12
  var _Pagination = _interopRequireDefault(require("./Pagination.native"));
13
- var _Icons = require("./Icons.native");
14
13
  var _theme = require("./theme");
15
14
  var _jsxRuntime = require("react/jsx-runtime");
16
15
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
@@ -28,13 +27,21 @@ function _nonIterableRest() { throw new TypeError("Invalid attempt to destructur
28
27
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
29
28
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
30
29
  function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
31
- function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } // Note: You'll need to install react-native-video for video playback
30
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } // Icons are now passed via props, no need to import here
31
+ // Note: You'll need to install react-native-video for video playback
32
32
  // import Video from 'react-native-video'
33
33
  var _Dimensions$get = _reactNative.Dimensions.get('window'),
34
34
  SCREEN_WIDTH = _Dimensions$get.width;
35
35
  var NUM_COLUMNS = 3;
36
- var ITEM_MARGIN = 8;
37
- var ITEM_SIZE = (SCREEN_WIDTH - 40 - ITEM_MARGIN * (NUM_COLUMNS - 1) * 2) / NUM_COLUMNS;
36
+ var ITEM_MARGIN = 4; // Reduced margin for better fit
37
+ // Calculate item size accounting for:
38
+ // - Container padding (md = 12px on each side = 24px total)
39
+ // - Grid padding (2px on each side = 4px total)
40
+ // - Item margins between items (4px * 2 gaps = 8px total)
41
+ var CONTAINER_PADDING = 24; // paddingHorizontal md (12 * 2)
42
+ var GRID_PADDING = 4; // padding 2 on each side (2 * 2)
43
+ var TOTAL_MARGINS = ITEM_MARGIN * (NUM_COLUMNS - 1) * 2; // margins between items (4px * 2 gaps = 8px)
44
+ var ITEM_SIZE = (SCREEN_WIDTH - CONTAINER_PADDING - GRID_PADDING - TOTAL_MARGINS) / NUM_COLUMNS;
38
45
  var VIDEO_MIME_TYPES = ['video/mp4', 'video/quicktime', 'video/x-ms-wmv', 'video/h265', 'video/hevc', 'video/webm'];
39
46
  var VideosGallery = function VideosGallery(_ref) {
40
47
  var update_data = _ref.update_data,
@@ -43,6 +50,7 @@ var VideosGallery = function VideosGallery(_ref) {
43
50
  onError = _ref.onError,
44
51
  picker = _ref.picker,
45
52
  pickerOptions = _ref.pickerOptions,
53
+ icons = _ref.icons,
46
54
  _ref$theme = _ref.theme,
47
55
  theme = _ref$theme === void 0 ? _theme.defaultTheme : _ref$theme,
48
56
  containerStyle = _ref.containerStyle,
@@ -144,8 +152,8 @@ var VideosGallery = function VideosGallery(_ref) {
144
152
  onUploadError: onError,
145
153
  picker: picker,
146
154
  pickerOptions: pickerOptions,
147
- theme: theme,
148
- icon: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icons.CameraIcon, {})
155
+ icons: icons,
156
+ theme: theme
149
157
  })
150
158
  });
151
159
  }
@@ -209,7 +217,7 @@ var styles = _reactNative.StyleSheet.create({
209
217
  flex: 1
210
218
  },
211
219
  grid: {
212
- padding: 4
220
+ padding: 2 // Reduced padding for better fit
213
221
  },
214
222
  uploadContainer: {
215
223
  margin: ITEM_MARGIN
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tradly/asset",
3
- "version": "1.0.19",
3
+ "version": "1.0.20",
4
4
  "description": "A reusable media gallery component for uploading and selecting images, videos, and files with Tradly authentication",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/esm/index.js",