@tradly/asset 1.0.18 → 1.0.19
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/dist/core/MediaApiService.js +91 -47
- package/dist/esm/core/MediaApiService.js +91 -47
- package/dist/esm/native/FileUpload.native.js +13 -3
- package/dist/esm/native/MediaGallery.native.js +2 -1
- package/dist/esm/native/MediaPopup.native.js +4 -2
- package/dist/esm/native/MediaTab.native.js +8 -3
- package/dist/native/FileUpload.native.js +13 -3
- package/dist/native/MediaGallery.native.js +2 -1
- package/dist/native/MediaPopup.native.js +4 -2
- package/dist/native/MediaTab.native.js +8 -3
- package/package.json +1 -1
|
@@ -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,
|
|
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;
|
|
253
253
|
return _regenerator().w(function (_context4) {
|
|
254
254
|
while (1) switch (_context4.p = _context4.n) {
|
|
255
255
|
case 0:
|
|
@@ -266,7 +266,7 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
266
266
|
i = 0;
|
|
267
267
|
case 2:
|
|
268
268
|
if (!(i < files.length)) {
|
|
269
|
-
_context4.n =
|
|
269
|
+
_context4.n = 27;
|
|
270
270
|
break;
|
|
271
271
|
}
|
|
272
272
|
element = files[i]; // Check if file already has a path (from previous upload)
|
|
@@ -284,7 +284,7 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
284
284
|
|
|
285
285
|
// Upload files when we've processed all files
|
|
286
286
|
if (!(files.length === i + 1 && upload_files.length > 0)) {
|
|
287
|
-
_context4.n =
|
|
287
|
+
_context4.n = 26;
|
|
288
288
|
break;
|
|
289
289
|
}
|
|
290
290
|
_context4.p = 3;
|
|
@@ -295,7 +295,7 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
295
295
|
index = 0;
|
|
296
296
|
case 5:
|
|
297
297
|
if (!(index < responseFiles.length)) {
|
|
298
|
-
_context4.n =
|
|
298
|
+
_context4.n = 23;
|
|
299
299
|
break;
|
|
300
300
|
}
|
|
301
301
|
path = responseFiles[index].signedUrl;
|
|
@@ -305,73 +305,117 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
305
305
|
fileBody = originalFile; // Handle React Native file URIs
|
|
306
306
|
// If file has a uri property, it's from React Native - fetch it first
|
|
307
307
|
if (!(originalFile.uri && typeof originalFile.uri === "string")) {
|
|
308
|
-
_context4.n =
|
|
308
|
+
_context4.n = 16;
|
|
309
309
|
break;
|
|
310
310
|
}
|
|
311
311
|
// For React Native, handle file://, content://, or http:// URIs
|
|
312
312
|
uri = originalFile.uri;
|
|
313
313
|
_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);
|
|
314
317
|
_context4.n = 8;
|
|
315
318
|
return fetch(uri);
|
|
316
319
|
case 8:
|
|
317
320
|
fileResponse = _context4.v;
|
|
321
|
+
if (fileResponse.ok) {
|
|
322
|
+
_context4.n = 9;
|
|
323
|
+
break;
|
|
324
|
+
}
|
|
325
|
+
throw new Error("Failed to fetch file: ".concat(fileResponse.status, " ").concat(fileResponse.statusText));
|
|
326
|
+
case 9:
|
|
318
327
|
if (!fileResponse.blob) {
|
|
319
|
-
_context4.n =
|
|
328
|
+
_context4.n = 11;
|
|
320
329
|
break;
|
|
321
330
|
}
|
|
322
|
-
_context4.n =
|
|
331
|
+
_context4.n = 10;
|
|
323
332
|
return fileResponse.blob();
|
|
324
|
-
case 9:
|
|
325
|
-
blob = _context4.v;
|
|
326
|
-
fileBody = blob;
|
|
327
|
-
_context4.n = 11;
|
|
328
|
-
break;
|
|
329
333
|
case 10:
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
case 11:
|
|
334
|
-
_context4.n = 13;
|
|
334
|
+
fileBody = _context4.v;
|
|
335
|
+
console.log("File converted to blob, size:", fileBody.size);
|
|
336
|
+
_context4.n = 14;
|
|
335
337
|
break;
|
|
338
|
+
case 11:
|
|
339
|
+
if (!fileResponse.arrayBuffer) {
|
|
340
|
+
_context4.n = 13;
|
|
341
|
+
break;
|
|
342
|
+
}
|
|
343
|
+
_context4.n = 12;
|
|
344
|
+
return fileResponse.arrayBuffer();
|
|
336
345
|
case 12:
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
346
|
+
arrayBuffer = _context4.v;
|
|
347
|
+
// Check if Blob constructor is available
|
|
348
|
+
if (typeof Blob !== "undefined") {
|
|
349
|
+
fileBody = new Blob([arrayBuffer], {
|
|
350
|
+
type: upload_files[index].type
|
|
351
|
+
});
|
|
352
|
+
} else {
|
|
353
|
+
// If Blob is not available, use arrayBuffer directly
|
|
354
|
+
fileBody = arrayBuffer;
|
|
355
|
+
}
|
|
347
356
|
_context4.n = 14;
|
|
357
|
+
break;
|
|
358
|
+
case 13:
|
|
359
|
+
// Last resort: use response directly (might not work for all cases)
|
|
360
|
+
fileBody = fileResponse;
|
|
361
|
+
case 14:
|
|
362
|
+
_context4.n = 16;
|
|
363
|
+
break;
|
|
364
|
+
case 15:
|
|
365
|
+
_context4.p = 15;
|
|
366
|
+
_t3 = _context4.v;
|
|
367
|
+
console.error("Error fetching file from URI:", _t3);
|
|
368
|
+
console.error("URI was:", uri);
|
|
369
|
+
console.error("File details:", {
|
|
370
|
+
name: originalFile.name,
|
|
371
|
+
type: originalFile.type
|
|
372
|
+
});
|
|
373
|
+
throw new Error("Failed to read file from URI: ".concat(uri, ". Error: ").concat(_t3.message, ". Make sure the file URI is accessible."));
|
|
374
|
+
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
|
+
_context4.n = 17;
|
|
348
379
|
return fetch(path, {
|
|
349
380
|
method: "PUT",
|
|
350
381
|
headers: {
|
|
351
|
-
|
|
382
|
+
"Content-Type": upload_files[index].type
|
|
352
383
|
},
|
|
353
384
|
body: fileBody
|
|
354
385
|
});
|
|
355
|
-
case
|
|
386
|
+
case 17:
|
|
356
387
|
res = _context4.v;
|
|
357
|
-
if (res.ok) {
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
console.error("Failed to upload file ".concat(index + 1));
|
|
388
|
+
if (!res.ok) {
|
|
389
|
+
_context4.n = 18;
|
|
390
|
+
break;
|
|
361
391
|
}
|
|
362
|
-
|
|
392
|
+
console.log("File ".concat(index + 1, " uploaded successfully"));
|
|
393
|
+
all_files_uri.push(fileURI);
|
|
394
|
+
_context4.n = 20;
|
|
363
395
|
break;
|
|
364
|
-
case
|
|
365
|
-
_context4.
|
|
396
|
+
case 18:
|
|
397
|
+
_context4.n = 19;
|
|
398
|
+
return res.text().catch(function () {
|
|
399
|
+
return "";
|
|
400
|
+
});
|
|
401
|
+
case 19:
|
|
402
|
+
errorText = _context4.v;
|
|
403
|
+
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));
|
|
405
|
+
case 20:
|
|
406
|
+
_context4.n = 22;
|
|
407
|
+
break;
|
|
408
|
+
case 21:
|
|
409
|
+
_context4.p = 21;
|
|
366
410
|
_t4 = _context4.v;
|
|
367
411
|
console.error("Error uploading file ".concat(index + 1, ":"), _t4);
|
|
368
|
-
case
|
|
412
|
+
case 22:
|
|
369
413
|
index++;
|
|
370
414
|
_context4.n = 5;
|
|
371
415
|
break;
|
|
372
|
-
case
|
|
416
|
+
case 23:
|
|
373
417
|
if (!(all_files_uri.length > 0)) {
|
|
374
|
-
_context4.n =
|
|
418
|
+
_context4.n = 24;
|
|
375
419
|
break;
|
|
376
420
|
}
|
|
377
421
|
mediaData = all_files_uri.map(function (url, index) {
|
|
@@ -384,7 +428,7 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
384
428
|
mime_type: originalFile.type
|
|
385
429
|
};
|
|
386
430
|
}); // Save to media API - POST /v1/media with { media: [...] }
|
|
387
|
-
_context4.n =
|
|
431
|
+
_context4.n = 24;
|
|
388
432
|
return this.apiCall({
|
|
389
433
|
method: "POST",
|
|
390
434
|
path: "/v1/media",
|
|
@@ -392,25 +436,25 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
392
436
|
media: mediaData
|
|
393
437
|
}
|
|
394
438
|
});
|
|
395
|
-
case
|
|
396
|
-
_context4.n =
|
|
439
|
+
case 24:
|
|
440
|
+
_context4.n = 26;
|
|
397
441
|
break;
|
|
398
|
-
case
|
|
399
|
-
_context4.p =
|
|
442
|
+
case 25:
|
|
443
|
+
_context4.p = 25;
|
|
400
444
|
_t5 = _context4.v;
|
|
401
445
|
console.error("Upload error:", _t5);
|
|
402
446
|
if (this.onError) {
|
|
403
447
|
this.onError(_t5);
|
|
404
448
|
}
|
|
405
449
|
throw _t5;
|
|
406
|
-
case
|
|
450
|
+
case 26:
|
|
407
451
|
i++;
|
|
408
452
|
_context4.n = 2;
|
|
409
453
|
break;
|
|
410
|
-
case
|
|
454
|
+
case 27:
|
|
411
455
|
return _context4.a(2, all_files_uri);
|
|
412
456
|
}
|
|
413
|
-
}, _callee4, this, [[7,
|
|
457
|
+
}, _callee4, this, [[7, 15], [6, 21], [3, 25]]);
|
|
414
458
|
}));
|
|
415
459
|
function uploadMedia(_x5, _x6) {
|
|
416
460
|
return _uploadMedia.apply(this, arguments);
|
|
@@ -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,
|
|
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;
|
|
247
247
|
return _regenerator().w(function (_context4) {
|
|
248
248
|
while (1) switch (_context4.p = _context4.n) {
|
|
249
249
|
case 0:
|
|
@@ -260,7 +260,7 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
260
260
|
i = 0;
|
|
261
261
|
case 2:
|
|
262
262
|
if (!(i < files.length)) {
|
|
263
|
-
_context4.n =
|
|
263
|
+
_context4.n = 27;
|
|
264
264
|
break;
|
|
265
265
|
}
|
|
266
266
|
element = files[i]; // Check if file already has a path (from previous upload)
|
|
@@ -278,7 +278,7 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
278
278
|
|
|
279
279
|
// Upload files when we've processed all files
|
|
280
280
|
if (!(files.length === i + 1 && upload_files.length > 0)) {
|
|
281
|
-
_context4.n =
|
|
281
|
+
_context4.n = 26;
|
|
282
282
|
break;
|
|
283
283
|
}
|
|
284
284
|
_context4.p = 3;
|
|
@@ -289,7 +289,7 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
289
289
|
index = 0;
|
|
290
290
|
case 5:
|
|
291
291
|
if (!(index < responseFiles.length)) {
|
|
292
|
-
_context4.n =
|
|
292
|
+
_context4.n = 23;
|
|
293
293
|
break;
|
|
294
294
|
}
|
|
295
295
|
path = responseFiles[index].signedUrl;
|
|
@@ -299,73 +299,117 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
299
299
|
fileBody = originalFile; // Handle React Native file URIs
|
|
300
300
|
// If file has a uri property, it's from React Native - fetch it first
|
|
301
301
|
if (!(originalFile.uri && typeof originalFile.uri === "string")) {
|
|
302
|
-
_context4.n =
|
|
302
|
+
_context4.n = 16;
|
|
303
303
|
break;
|
|
304
304
|
}
|
|
305
305
|
// For React Native, handle file://, content://, or http:// URIs
|
|
306
306
|
uri = originalFile.uri;
|
|
307
307
|
_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);
|
|
308
311
|
_context4.n = 8;
|
|
309
312
|
return fetch(uri);
|
|
310
313
|
case 8:
|
|
311
314
|
fileResponse = _context4.v;
|
|
315
|
+
if (fileResponse.ok) {
|
|
316
|
+
_context4.n = 9;
|
|
317
|
+
break;
|
|
318
|
+
}
|
|
319
|
+
throw new Error("Failed to fetch file: ".concat(fileResponse.status, " ").concat(fileResponse.statusText));
|
|
320
|
+
case 9:
|
|
312
321
|
if (!fileResponse.blob) {
|
|
313
|
-
_context4.n =
|
|
322
|
+
_context4.n = 11;
|
|
314
323
|
break;
|
|
315
324
|
}
|
|
316
|
-
_context4.n =
|
|
325
|
+
_context4.n = 10;
|
|
317
326
|
return fileResponse.blob();
|
|
318
|
-
case 9:
|
|
319
|
-
blob = _context4.v;
|
|
320
|
-
fileBody = blob;
|
|
321
|
-
_context4.n = 11;
|
|
322
|
-
break;
|
|
323
327
|
case 10:
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
case 11:
|
|
328
|
-
_context4.n = 13;
|
|
328
|
+
fileBody = _context4.v;
|
|
329
|
+
console.log("File converted to blob, size:", fileBody.size);
|
|
330
|
+
_context4.n = 14;
|
|
329
331
|
break;
|
|
332
|
+
case 11:
|
|
333
|
+
if (!fileResponse.arrayBuffer) {
|
|
334
|
+
_context4.n = 13;
|
|
335
|
+
break;
|
|
336
|
+
}
|
|
337
|
+
_context4.n = 12;
|
|
338
|
+
return fileResponse.arrayBuffer();
|
|
330
339
|
case 12:
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
340
|
+
arrayBuffer = _context4.v;
|
|
341
|
+
// Check if Blob constructor is available
|
|
342
|
+
if (typeof Blob !== "undefined") {
|
|
343
|
+
fileBody = new Blob([arrayBuffer], {
|
|
344
|
+
type: upload_files[index].type
|
|
345
|
+
});
|
|
346
|
+
} else {
|
|
347
|
+
// If Blob is not available, use arrayBuffer directly
|
|
348
|
+
fileBody = arrayBuffer;
|
|
349
|
+
}
|
|
341
350
|
_context4.n = 14;
|
|
351
|
+
break;
|
|
352
|
+
case 13:
|
|
353
|
+
// Last resort: use response directly (might not work for all cases)
|
|
354
|
+
fileBody = fileResponse;
|
|
355
|
+
case 14:
|
|
356
|
+
_context4.n = 16;
|
|
357
|
+
break;
|
|
358
|
+
case 15:
|
|
359
|
+
_context4.p = 15;
|
|
360
|
+
_t3 = _context4.v;
|
|
361
|
+
console.error("Error fetching file from URI:", _t3);
|
|
362
|
+
console.error("URI was:", uri);
|
|
363
|
+
console.error("File details:", {
|
|
364
|
+
name: originalFile.name,
|
|
365
|
+
type: originalFile.type
|
|
366
|
+
});
|
|
367
|
+
throw new Error("Failed to read file from URI: ".concat(uri, ". Error: ").concat(_t3.message, ". Make sure the file URI is accessible."));
|
|
368
|
+
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
|
+
_context4.n = 17;
|
|
342
373
|
return fetch(path, {
|
|
343
374
|
method: "PUT",
|
|
344
375
|
headers: {
|
|
345
|
-
|
|
376
|
+
"Content-Type": upload_files[index].type
|
|
346
377
|
},
|
|
347
378
|
body: fileBody
|
|
348
379
|
});
|
|
349
|
-
case
|
|
380
|
+
case 17:
|
|
350
381
|
res = _context4.v;
|
|
351
|
-
if (res.ok) {
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
console.error("Failed to upload file ".concat(index + 1));
|
|
382
|
+
if (!res.ok) {
|
|
383
|
+
_context4.n = 18;
|
|
384
|
+
break;
|
|
355
385
|
}
|
|
356
|
-
|
|
386
|
+
console.log("File ".concat(index + 1, " uploaded successfully"));
|
|
387
|
+
all_files_uri.push(fileURI);
|
|
388
|
+
_context4.n = 20;
|
|
357
389
|
break;
|
|
358
|
-
case
|
|
359
|
-
_context4.
|
|
390
|
+
case 18:
|
|
391
|
+
_context4.n = 19;
|
|
392
|
+
return res.text().catch(function () {
|
|
393
|
+
return "";
|
|
394
|
+
});
|
|
395
|
+
case 19:
|
|
396
|
+
errorText = _context4.v;
|
|
397
|
+
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));
|
|
399
|
+
case 20:
|
|
400
|
+
_context4.n = 22;
|
|
401
|
+
break;
|
|
402
|
+
case 21:
|
|
403
|
+
_context4.p = 21;
|
|
360
404
|
_t4 = _context4.v;
|
|
361
405
|
console.error("Error uploading file ".concat(index + 1, ":"), _t4);
|
|
362
|
-
case
|
|
406
|
+
case 22:
|
|
363
407
|
index++;
|
|
364
408
|
_context4.n = 5;
|
|
365
409
|
break;
|
|
366
|
-
case
|
|
410
|
+
case 23:
|
|
367
411
|
if (!(all_files_uri.length > 0)) {
|
|
368
|
-
_context4.n =
|
|
412
|
+
_context4.n = 24;
|
|
369
413
|
break;
|
|
370
414
|
}
|
|
371
415
|
mediaData = all_files_uri.map(function (url, index) {
|
|
@@ -378,7 +422,7 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
378
422
|
mime_type: originalFile.type
|
|
379
423
|
};
|
|
380
424
|
}); // Save to media API - POST /v1/media with { media: [...] }
|
|
381
|
-
_context4.n =
|
|
425
|
+
_context4.n = 24;
|
|
382
426
|
return this.apiCall({
|
|
383
427
|
method: "POST",
|
|
384
428
|
path: "/v1/media",
|
|
@@ -386,25 +430,25 @@ var MediaApiService = /*#__PURE__*/function () {
|
|
|
386
430
|
media: mediaData
|
|
387
431
|
}
|
|
388
432
|
});
|
|
389
|
-
case
|
|
390
|
-
_context4.n =
|
|
433
|
+
case 24:
|
|
434
|
+
_context4.n = 26;
|
|
391
435
|
break;
|
|
392
|
-
case
|
|
393
|
-
_context4.p =
|
|
436
|
+
case 25:
|
|
437
|
+
_context4.p = 25;
|
|
394
438
|
_t5 = _context4.v;
|
|
395
439
|
console.error("Upload error:", _t5);
|
|
396
440
|
if (this.onError) {
|
|
397
441
|
this.onError(_t5);
|
|
398
442
|
}
|
|
399
443
|
throw _t5;
|
|
400
|
-
case
|
|
444
|
+
case 26:
|
|
401
445
|
i++;
|
|
402
446
|
_context4.n = 2;
|
|
403
447
|
break;
|
|
404
|
-
case
|
|
448
|
+
case 27:
|
|
405
449
|
return _context4.a(2, all_files_uri);
|
|
406
450
|
}
|
|
407
|
-
}, _callee4, this, [[7,
|
|
451
|
+
}, _callee4, this, [[7, 15], [6, 21], [3, 25]]);
|
|
408
452
|
}));
|
|
409
453
|
function uploadMedia(_x5, _x6) {
|
|
410
454
|
return _uploadMedia.apply(this, arguments);
|
|
@@ -153,7 +153,16 @@ var FileUpload = function FileUpload(_ref) {
|
|
|
153
153
|
setUploadProgress(0);
|
|
154
154
|
_context.p = 1;
|
|
155
155
|
// Convert picker results to File-like objects
|
|
156
|
-
filesToUpload = fileList.map(convertToFile); //
|
|
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
|
|
157
166
|
// Note: uploadMedia will need to handle React Native file URIs
|
|
158
167
|
_context.n = 2;
|
|
159
168
|
return apiService.uploadMedia(filesToUpload, apiService.authKey);
|
|
@@ -311,7 +320,7 @@ var FileUpload = function FileUpload(_ref) {
|
|
|
311
320
|
var styles = StyleSheet.create({
|
|
312
321
|
container: {
|
|
313
322
|
width: "100%",
|
|
314
|
-
height:
|
|
323
|
+
height: "100%"
|
|
315
324
|
},
|
|
316
325
|
button: {
|
|
317
326
|
width: "100%",
|
|
@@ -327,11 +336,12 @@ var styles = StyleSheet.create({
|
|
|
327
336
|
// Colors and spacing applied via theme
|
|
328
337
|
},
|
|
329
338
|
title: {
|
|
339
|
+
textAlign: "center"
|
|
330
340
|
// Colors and typography applied via theme
|
|
331
341
|
},
|
|
332
342
|
loadingContainer: {
|
|
333
343
|
width: "100%",
|
|
334
|
-
height:
|
|
344
|
+
height: "100%",
|
|
335
345
|
justifyContent: "center",
|
|
336
346
|
alignItems: "center"
|
|
337
347
|
// Colors applied via theme
|
|
@@ -86,7 +86,9 @@ var MediaPopup = function MediaPopup(_ref) {
|
|
|
86
86
|
borderTopRightRadius: currentTheme.radius.xxl,
|
|
87
87
|
height: SCREEN_HEIGHT * sheetHeight,
|
|
88
88
|
maxHeight: SCREEN_HEIGHT * sheetHeight,
|
|
89
|
-
|
|
89
|
+
paddingTop: currentTheme.spacing.sm,
|
|
90
|
+
paddingBottom: currentTheme.spacing.xl,
|
|
91
|
+
paddingHorizontal: currentTheme.spacing.xl
|
|
90
92
|
}, containerStyle, {
|
|
91
93
|
transform: [{
|
|
92
94
|
translateY: slideAnim
|
|
@@ -94,7 +96,7 @@ var MediaPopup = function MediaPopup(_ref) {
|
|
|
94
96
|
}],
|
|
95
97
|
children: [/*#__PURE__*/_jsxs(View, {
|
|
96
98
|
style: [styles.header, {
|
|
97
|
-
marginBottom: currentTheme.spacing.
|
|
99
|
+
marginBottom: currentTheme.spacing.sm
|
|
98
100
|
}, headerStyle],
|
|
99
101
|
children: [/*#__PURE__*/_jsx(Text, {
|
|
100
102
|
style: [styles.title, {
|
|
@@ -105,11 +105,13 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
105
105
|
backgroundColor: theme.colors.tabBackground,
|
|
106
106
|
borderBottomColor: theme.colors.border,
|
|
107
107
|
paddingHorizontal: theme.spacing.xs,
|
|
108
|
-
// Always left align
|
|
109
|
-
justifyContent: "flex-start"
|
|
108
|
+
// Always left align - no center alignment
|
|
109
|
+
justifyContent: "flex-start",
|
|
110
|
+
alignItems: "flex-start"
|
|
110
111
|
}, tabListStyle],
|
|
111
112
|
children: availableTabs.map(function (type, index) {
|
|
112
113
|
var isSelected = index === selectedIndex;
|
|
114
|
+
var isSingleTab = availableTabs.length === 1;
|
|
113
115
|
return /*#__PURE__*/_jsxs(TouchableOpacity, {
|
|
114
116
|
onPress: function onPress() {
|
|
115
117
|
return setSelectedIndex(index);
|
|
@@ -117,7 +119,10 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
117
119
|
style: [styles.tabButton, {
|
|
118
120
|
paddingVertical: theme.spacing.md,
|
|
119
121
|
paddingHorizontal: theme.spacing.lg,
|
|
120
|
-
flex: 1
|
|
122
|
+
// For single tab, don't use flex: 1 to prevent centering
|
|
123
|
+
// Use auto width so it stays left-aligned
|
|
124
|
+
flex: isSingleTab ? 0 : 1,
|
|
125
|
+
alignSelf: "flex-start"
|
|
121
126
|
}, tabButtonStyle, isSelected ? [styles.tabButtonActive, tabButtonActiveStyle] : [styles.tabButtonInactive, tabButtonInactiveStyle]],
|
|
122
127
|
children: [/*#__PURE__*/_jsx(Text, {
|
|
123
128
|
style: [styles.tabButtonText, {
|
|
@@ -159,7 +159,16 @@ var FileUpload = function FileUpload(_ref) {
|
|
|
159
159
|
setUploadProgress(0);
|
|
160
160
|
_context.p = 1;
|
|
161
161
|
// Convert picker results to File-like objects
|
|
162
|
-
filesToUpload = fileList.map(convertToFile); //
|
|
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
|
|
163
172
|
// Note: uploadMedia will need to handle React Native file URIs
|
|
164
173
|
_context.n = 2;
|
|
165
174
|
return apiService.uploadMedia(filesToUpload, apiService.authKey);
|
|
@@ -317,7 +326,7 @@ var FileUpload = function FileUpload(_ref) {
|
|
|
317
326
|
var styles = _reactNative.StyleSheet.create({
|
|
318
327
|
container: {
|
|
319
328
|
width: "100%",
|
|
320
|
-
height:
|
|
329
|
+
height: "100%"
|
|
321
330
|
},
|
|
322
331
|
button: {
|
|
323
332
|
width: "100%",
|
|
@@ -333,11 +342,12 @@ var styles = _reactNative.StyleSheet.create({
|
|
|
333
342
|
// Colors and spacing applied via theme
|
|
334
343
|
},
|
|
335
344
|
title: {
|
|
345
|
+
textAlign: "center"
|
|
336
346
|
// Colors and typography applied via theme
|
|
337
347
|
},
|
|
338
348
|
loadingContainer: {
|
|
339
349
|
width: "100%",
|
|
340
|
-
height:
|
|
350
|
+
height: "100%",
|
|
341
351
|
justifyContent: "center",
|
|
342
352
|
alignItems: "center"
|
|
343
353
|
// Colors applied via theme
|
|
@@ -93,7 +93,9 @@ var MediaPopup = function MediaPopup(_ref) {
|
|
|
93
93
|
borderTopRightRadius: currentTheme.radius.xxl,
|
|
94
94
|
height: SCREEN_HEIGHT * sheetHeight,
|
|
95
95
|
maxHeight: SCREEN_HEIGHT * sheetHeight,
|
|
96
|
-
|
|
96
|
+
paddingTop: currentTheme.spacing.sm,
|
|
97
|
+
paddingBottom: currentTheme.spacing.xl,
|
|
98
|
+
paddingHorizontal: currentTheme.spacing.xl
|
|
97
99
|
}, containerStyle, {
|
|
98
100
|
transform: [{
|
|
99
101
|
translateY: slideAnim
|
|
@@ -101,7 +103,7 @@ var MediaPopup = function MediaPopup(_ref) {
|
|
|
101
103
|
}],
|
|
102
104
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
|
|
103
105
|
style: [styles.header, {
|
|
104
|
-
marginBottom: currentTheme.spacing.
|
|
106
|
+
marginBottom: currentTheme.spacing.sm
|
|
105
107
|
}, headerStyle],
|
|
106
108
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
107
109
|
style: [styles.title, {
|
|
@@ -114,11 +114,13 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
114
114
|
backgroundColor: theme.colors.tabBackground,
|
|
115
115
|
borderBottomColor: theme.colors.border,
|
|
116
116
|
paddingHorizontal: theme.spacing.xs,
|
|
117
|
-
// Always left align
|
|
118
|
-
justifyContent: "flex-start"
|
|
117
|
+
// Always left align - no center alignment
|
|
118
|
+
justifyContent: "flex-start",
|
|
119
|
+
alignItems: "flex-start"
|
|
119
120
|
}, tabListStyle],
|
|
120
121
|
children: availableTabs.map(function (type, index) {
|
|
121
122
|
var isSelected = index === selectedIndex;
|
|
123
|
+
var isSingleTab = availableTabs.length === 1;
|
|
122
124
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.TouchableOpacity, {
|
|
123
125
|
onPress: function onPress() {
|
|
124
126
|
return setSelectedIndex(index);
|
|
@@ -126,7 +128,10 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
126
128
|
style: [styles.tabButton, {
|
|
127
129
|
paddingVertical: theme.spacing.md,
|
|
128
130
|
paddingHorizontal: theme.spacing.lg,
|
|
129
|
-
flex: 1
|
|
131
|
+
// For single tab, don't use flex: 1 to prevent centering
|
|
132
|
+
// Use auto width so it stays left-aligned
|
|
133
|
+
flex: isSingleTab ? 0 : 1,
|
|
134
|
+
alignSelf: "flex-start"
|
|
130
135
|
}, tabButtonStyle, isSelected ? [styles.tabButtonActive, tabButtonActiveStyle] : [styles.tabButtonInactive, tabButtonInactiveStyle]],
|
|
131
136
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
|
|
132
137
|
style: [styles.tabButtonText, {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tradly/asset",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
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",
|