@tradly/asset 1.0.13 → 1.0.15

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.
Files changed (76) hide show
  1. package/README.md +414 -13
  2. package/dist/components/FileUpload.js +8 -254
  3. package/dist/components/FileUpload.native.js +13 -0
  4. package/dist/components/Icons.js +10 -33
  5. package/dist/components/Icons.native.js +16 -0
  6. package/dist/components/ImagesSkeleton.js +7 -15
  7. package/dist/components/ImagesSkeleton.native.js +13 -0
  8. package/dist/components/MediaGallery.js +8 -148
  9. package/dist/components/MediaGallery.native.js +13 -0
  10. package/dist/components/MediaPopup.js +8 -99
  11. package/dist/components/MediaPopup.native.js +13 -0
  12. package/dist/components/MediaTab.js +7 -180
  13. package/dist/components/MediaTab.native.js +13 -0
  14. package/dist/components/Pagination.js +8 -136
  15. package/dist/components/Pagination.native.js +13 -0
  16. package/dist/components/VideosGallery.js +8 -148
  17. package/dist/components/VideosGallery.native.js +13 -0
  18. package/dist/core/MediaApiService.js +396 -0
  19. package/dist/esm/components/FileUpload.js +1 -253
  20. package/dist/esm/components/FileUpload.native.js +1 -0
  21. package/dist/esm/components/Icons.js +1 -32
  22. package/dist/esm/components/Icons.native.js +1 -0
  23. package/dist/esm/components/ImagesSkeleton.js +1 -14
  24. package/dist/esm/components/ImagesSkeleton.native.js +1 -0
  25. package/dist/esm/components/MediaGallery.js +1 -144
  26. package/dist/esm/components/MediaGallery.native.js +1 -0
  27. package/dist/esm/components/MediaPopup.js +1 -97
  28. package/dist/esm/components/MediaPopup.native.js +1 -0
  29. package/dist/esm/components/MediaTab.js +1 -177
  30. package/dist/esm/components/MediaTab.native.js +1 -0
  31. package/dist/esm/components/Pagination.js +1 -134
  32. package/dist/esm/components/Pagination.native.js +1 -0
  33. package/dist/esm/components/VideosGallery.js +1 -144
  34. package/dist/esm/components/VideosGallery.native.js +1 -0
  35. package/dist/esm/core/MediaApiService.js +390 -0
  36. package/dist/esm/index.js +4 -1
  37. package/dist/esm/native/FileUpload.native.js +310 -0
  38. package/dist/esm/native/Icons.native.js +51 -0
  39. package/dist/esm/native/ImagesSkeleton.native.js +45 -0
  40. package/dist/esm/native/MediaGallery.native.js +228 -0
  41. package/dist/esm/native/MediaPopup.native.js +170 -0
  42. package/dist/esm/native/MediaTab.native.js +192 -0
  43. package/dist/esm/native/Pagination.native.js +210 -0
  44. package/dist/esm/native/THEME_EXAMPLE.js +112 -0
  45. package/dist/esm/native/VideosGallery.native.js +240 -0
  46. package/dist/esm/native/theme.js +167 -0
  47. package/dist/esm/services/apiService.js +1 -372
  48. package/dist/esm/web/FileUpload.web.js +253 -0
  49. package/dist/esm/web/Icons.web.js +32 -0
  50. package/dist/esm/web/ImagesSkeleton.web.js +14 -0
  51. package/dist/esm/web/MediaGallery.web.js +144 -0
  52. package/dist/esm/web/MediaPopup.web.js +97 -0
  53. package/dist/esm/web/MediaTab.web.js +177 -0
  54. package/dist/esm/web/Pagination.web.js +134 -0
  55. package/dist/esm/web/VideosGallery.web.js +144 -0
  56. package/dist/index.js +16 -2
  57. package/dist/native/FileUpload.native.js +316 -0
  58. package/dist/native/Icons.native.js +59 -0
  59. package/dist/native/ImagesSkeleton.native.js +52 -0
  60. package/dist/native/MediaGallery.native.js +237 -0
  61. package/dist/native/MediaPopup.native.js +177 -0
  62. package/dist/native/MediaTab.native.js +201 -0
  63. package/dist/native/Pagination.native.js +217 -0
  64. package/dist/native/THEME_EXAMPLE.js +117 -0
  65. package/dist/native/VideosGallery.native.js +248 -0
  66. package/dist/native/theme.js +173 -0
  67. package/dist/services/apiService.js +2 -372
  68. package/dist/web/FileUpload.web.js +259 -0
  69. package/dist/web/Icons.web.js +39 -0
  70. package/dist/web/ImagesSkeleton.web.js +21 -0
  71. package/dist/web/MediaGallery.web.js +153 -0
  72. package/dist/web/MediaPopup.web.js +104 -0
  73. package/dist/web/MediaTab.web.js +186 -0
  74. package/dist/web/Pagination.web.js +141 -0
  75. package/dist/web/VideosGallery.web.js +153 -0
  76. package/package.json +3 -2
@@ -0,0 +1,144 @@
1
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
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
+ 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
+ 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 _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
6
+ 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
+ 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; } }
8
+ 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; }
9
+ 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; } }
10
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
11
+ import React, { useState, useEffect } from 'react';
12
+ import FileUpload from './FileUpload.web';
13
+ import ImagesSkeleton from './ImagesSkeleton.web';
14
+ import Pagination from './Pagination.web';
15
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
16
+ var VIDEO_MIME_TYPES = ['video/mp4', 'video/quicktime', 'video/x-ms-wmv', 'video/h265', 'video/hevc', 'video/webm'];
17
+ var VideosGallery = function VideosGallery(_ref) {
18
+ var update_data = _ref.update_data,
19
+ closePopup = _ref.closePopup,
20
+ apiService = _ref.apiService,
21
+ onError = _ref.onError,
22
+ className = _ref.className,
23
+ gridClassName = _ref.gridClassName,
24
+ videoItemClassName = _ref.videoItemClassName,
25
+ paginationContainerClassName = _ref.paginationContainerClassName;
26
+ var _useState = useState([]),
27
+ _useState2 = _slicedToArray(_useState, 2),
28
+ videos = _useState2[0],
29
+ setVideos = _useState2[1];
30
+ var _useState3 = useState(0),
31
+ _useState4 = _slicedToArray(_useState3, 2),
32
+ total_count = _useState4[0],
33
+ setTotalCount = _useState4[1];
34
+ var _useState5 = useState(1),
35
+ _useState6 = _slicedToArray(_useState5, 2),
36
+ currentPage = _useState6[0],
37
+ setCurrentPage = _useState6[1];
38
+ var _useState7 = useState(false),
39
+ _useState8 = _slicedToArray(_useState7, 2),
40
+ isLoading = _useState8[0],
41
+ setISLoading = _useState8[1];
42
+
43
+ // Fetch videos
44
+ useEffect(function () {
45
+ loadMedia();
46
+ }, []);
47
+ var loadMedia = /*#__PURE__*/function () {
48
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
49
+ var page_number,
50
+ _response$data,
51
+ _response$data2,
52
+ response,
53
+ mediaData,
54
+ count,
55
+ _args = arguments,
56
+ _t;
57
+ return _regenerator().w(function (_context) {
58
+ while (1) switch (_context.p = _context.n) {
59
+ case 0:
60
+ page_number = _args.length > 0 && _args[0] !== undefined ? _args[0] : 1;
61
+ _context.p = 1;
62
+ _context.n = 2;
63
+ return apiService.fetchMedia({
64
+ mimeTypes: VIDEO_MIME_TYPES,
65
+ page: page_number,
66
+ setISLoading: setISLoading,
67
+ isLoading: isLoading
68
+ });
69
+ case 2:
70
+ response = _context.v;
71
+ // Handle different response formats
72
+ // Response might be: { media: [...], count: ... } or { data: { media: [...], count: ... } } or directly [...]
73
+ mediaData = (response === null || response === void 0 ? void 0 : response.media) || (response === null || response === void 0 || (_response$data = response.data) === null || _response$data === void 0 ? void 0 : _response$data.media) || (response === null || response === void 0 ? void 0 : response.data) || response || [];
74
+ count = (response === null || response === void 0 ? void 0 : response.count) || (response === null || response === void 0 || (_response$data2 = response.data) === null || _response$data2 === void 0 ? void 0 : _response$data2.count) || (response === null || response === void 0 ? void 0 : response.total) || 0;
75
+ setVideos(Array.isArray(mediaData) ? mediaData : []);
76
+ setTotalCount(count);
77
+ setCurrentPage(page_number);
78
+ _context.n = 4;
79
+ break;
80
+ case 3:
81
+ _context.p = 3;
82
+ _t = _context.v;
83
+ console.error('Error loading videos:', _t);
84
+ if (onError) {
85
+ onError(_t);
86
+ }
87
+ case 4:
88
+ return _context.a(2);
89
+ }
90
+ }, _callee, null, [[1, 3]]);
91
+ }));
92
+ return function loadMedia() {
93
+ return _ref2.apply(this, arguments);
94
+ };
95
+ }();
96
+ var handleVideoClick = function handleVideoClick(video) {
97
+ if (update_data) {
98
+ update_data(video.url || video);
99
+ }
100
+ if (closePopup) {
101
+ closePopup();
102
+ }
103
+ };
104
+
105
+ // Default classes with customization support
106
+ var defaultContainerClass = 'h-full flex flex-col justify-between';
107
+ var defaultGridClass = 'grid grid-cols-[repeat(auto-fill,minmax(calc(180px),1fr))] gap-5';
108
+ var defaultVideoItemClass = 'cursor-pointer w-full h-40 object-contain overflow-hidden bg-white rounded-md shadow-md hover:shadow-lg transition-shadow';
109
+ var defaultPaginationContainerClass = 'mb-4 bg-gray-100/90 p-4 sticky bottom-0';
110
+ return /*#__PURE__*/_jsxs("div", {
111
+ className: className || defaultContainerClass,
112
+ children: [/*#__PURE__*/_jsxs("div", {
113
+ className: gridClassName || defaultGridClass,
114
+ children: [/*#__PURE__*/_jsx(FileUpload, {
115
+ loadMedia: loadMedia,
116
+ accept: "video/*",
117
+ title: "Add Video",
118
+ apiService: apiService,
119
+ onUploadError: onError
120
+ }), isLoading ? /*#__PURE__*/_jsx(ImagesSkeleton, {}) : videos === null || videos === void 0 ? void 0 : videos.map(function (video, index) {
121
+ var videoUrl = typeof video === 'string' ? video : video.url;
122
+ var videoKey = video.id || video.url || index;
123
+ return /*#__PURE__*/_jsx("video", {
124
+ onClick: function onClick() {
125
+ return handleVideoClick(video);
126
+ },
127
+ className: videoItemClassName || defaultVideoItemClass,
128
+ controls: true,
129
+ src: videoUrl
130
+ }, videoKey);
131
+ })]
132
+ }), /*#__PURE__*/_jsx("div", {
133
+ className: paginationContainerClassName || defaultPaginationContainerClass,
134
+ children: total_count > 0 && /*#__PURE__*/_jsx(Pagination, {
135
+ nextPage: function nextPage(value) {
136
+ return loadMedia(value);
137
+ },
138
+ pageCount: Math.ceil(total_count / 30),
139
+ current_page: currentPage
140
+ })
141
+ })]
142
+ });
143
+ };
144
+ export default VideosGallery;
package/dist/index.js CHANGED
@@ -18,7 +18,7 @@ Object.defineProperty(exports, "ImagesGallery", {
18
18
  Object.defineProperty(exports, "MediaApiService", {
19
19
  enumerable: true,
20
20
  get: function get() {
21
- return _apiService.default;
21
+ return _MediaApiService.default;
22
22
  }
23
23
  });
24
24
  Object.defineProperty(exports, "MediaPopup", {
@@ -39,13 +39,26 @@ Object.defineProperty(exports, "VideosGallery", {
39
39
  return _VideosGallery.default;
40
40
  }
41
41
  });
42
+ Object.defineProperty(exports, "createTheme", {
43
+ enumerable: true,
44
+ get: function get() {
45
+ return _theme.createTheme;
46
+ }
47
+ });
42
48
  exports.default = void 0;
49
+ Object.defineProperty(exports, "defaultTheme", {
50
+ enumerable: true,
51
+ get: function get() {
52
+ return _theme.defaultTheme;
53
+ }
54
+ });
43
55
  var _MediaPopup = _interopRequireDefault(require("./components/MediaPopup"));
44
56
  var _MediaTab = _interopRequireDefault(require("./components/MediaTab"));
45
57
  var _MediaGallery = _interopRequireDefault(require("./components/MediaGallery"));
46
58
  var _VideosGallery = _interopRequireDefault(require("./components/VideosGallery"));
47
59
  var _FileUpload = _interopRequireDefault(require("./components/FileUpload"));
48
- var _apiService = _interopRequireDefault(require("./services/apiService"));
60
+ var _MediaApiService = _interopRequireDefault(require("./core/MediaApiService"));
61
+ var _theme = require("./native/theme");
49
62
  function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
50
63
  /**
51
64
  * @tradly/asset
@@ -56,5 +69,6 @@ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e
56
69
  // Export main component
57
70
  // Export sub-components for advanced usage
58
71
  // Export API service
72
+ // Export React Native theme utilities
59
73
  // Export default as MediaPopup for convenience
60
74
  var _default = exports.default = _MediaPopup.default;
@@ -0,0 +1,316 @@
1
+ "use strict";
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
+ Object.defineProperty(exports, "__esModule", {
5
+ value: true
6
+ });
7
+ exports.default = void 0;
8
+ var _react = _interopRequireWildcard(require("react"));
9
+ var _reactNative = require("react-native");
10
+ var _Icons = require("./Icons.native");
11
+ var _theme = require("./theme");
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ function _interopRequireWildcard(e, t) { if ("function" == typeof WeakMap) var r = new WeakMap(), n = new WeakMap(); return (_interopRequireWildcard = function _interopRequireWildcard(e, t) { if (!t && e && e.__esModule) return e; var o, i, f = { __proto__: null, default: e }; if (null === e || "object" != _typeof(e) && "function" != typeof e) return f; if (o = t ? n : r) { if (o.has(e)) return o.get(e); o.set(e, f); } for (var _t3 in e) "default" !== _t3 && {}.hasOwnProperty.call(e, _t3) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t3)) && (i.get || i.set) ? o(f, _t3, i) : f[_t3] = e[_t3]); return f; })(e, t); }
14
+ function _regenerator() { /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/babel/babel/blob/main/packages/babel-helpers/LICENSE */ var e, t, r = "function" == typeof Symbol ? Symbol : {}, n = r.iterator || "@@iterator", o = r.toStringTag || "@@toStringTag"; function i(r, n, o, i) { var c = n && n.prototype instanceof Generator ? n : Generator, u = Object.create(c.prototype); return _regeneratorDefine2(u, "_invoke", function (r, n, o) { var i, c, u, f = 0, p = o || [], y = !1, G = { p: 0, n: 0, v: e, a: d, f: d.bind(e, 4), d: function d(t, r) { return i = t, c = 0, u = e, G.n = r, a; } }; function d(r, n) { for (c = r, u = n, t = 0; !y && f && !o && t < p.length; t++) { var o, i = p[t], d = G.p, l = i[2]; r > 3 ? (o = l === n) && (u = i[(c = i[4]) ? 5 : (c = 3, 3)], i[4] = i[5] = e) : i[0] <= d && ((o = r < 2 && d < i[1]) ? (c = 0, G.v = n, G.n = i[1]) : d < l && (o = r < 3 || i[0] > n || n > l) && (i[4] = r, i[5] = n, G.n = l, c = 0)); } if (o || r > 1) return a; throw y = !0, n; } return function (o, p, l) { if (f > 1) throw TypeError("Generator is already running"); for (y && 1 === p && d(p, l), c = p, u = l; (t = c < 2 ? e : u) || !y;) { i || (c ? c < 3 ? (c > 1 && (G.n = -1), d(c, u)) : G.n = u : G.v = u); try { if (f = 2, i) { if (c || (o = "next"), t = i[o]) { if (!(t = t.call(i, u))) throw TypeError("iterator result is not an object"); if (!t.done) return t; u = t.value, c < 2 && (c = 0); } else 1 === c && (t = i.return) && t.call(i), c < 2 && (u = TypeError("The iterator does not provide a '" + o + "' method"), c = 1); i = e; } else if ((t = (y = G.n < 0) ? u : r.call(n, G)) !== a) break; } catch (t) { i = e, c = 1, u = t; } finally { f = 1; } } return { value: t, done: y }; }; }(r, o, i), !0), u; } var a = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} t = Object.getPrototypeOf; var c = [][n] ? t(t([][n]())) : (_regeneratorDefine2(t = {}, n, function () { return this; }), t), u = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(c); function f(e) { return Object.setPrototypeOf ? Object.setPrototypeOf(e, GeneratorFunctionPrototype) : (e.__proto__ = GeneratorFunctionPrototype, _regeneratorDefine2(e, o, "GeneratorFunction")), e.prototype = Object.create(u), e; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, _regeneratorDefine2(u, "constructor", GeneratorFunctionPrototype), _regeneratorDefine2(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = "GeneratorFunction", _regeneratorDefine2(GeneratorFunctionPrototype, o, "GeneratorFunction"), _regeneratorDefine2(u), _regeneratorDefine2(u, o, "Generator"), _regeneratorDefine2(u, n, function () { return this; }), _regeneratorDefine2(u, "toString", function () { return "[object Generator]"; }), (_regenerator = function _regenerator() { return { w: i, m: f }; })(); }
15
+ 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
+ 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
+ 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); }); }; }
18
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
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
+ 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; } }
21
+ 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; }
22
+ 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; } }
23
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; } /**
24
+ * FileUpload component for React Native
25
+ *
26
+ * USAGE EXAMPLES:
27
+ *
28
+ * 1. Using react-native-image-picker:
29
+ * import { launchImageLibrary } from 'react-native-image-picker'
30
+ *
31
+ * <MediaPopup
32
+ * picker={(options) => {
33
+ * return new Promise((resolve) => {
34
+ * launchImageLibrary(options, (response) => {
35
+ * resolve(response.assets || [])
36
+ * })
37
+ * })
38
+ * }}
39
+ * ...
40
+ * />
41
+ *
42
+ * 2. Using expo-image-picker:
43
+ * import * as ImagePicker from 'expo-image-picker'
44
+ *
45
+ * <MediaPopup
46
+ * picker={async (options) => {
47
+ * const result = await ImagePicker.launchImageLibraryAsync({
48
+ * mediaTypes: options.mediaType === 'photo' ? ImagePicker.MediaTypeOptions.Images
49
+ * : options.mediaType === 'video' ? ImagePicker.MediaTypeOptions.Videos
50
+ * : ImagePicker.MediaTypeOptions.All,
51
+ * allowsMultipleSelection: options.allowsMultiple,
52
+ * quality: options.quality,
53
+ * })
54
+ * return result.assets || []
55
+ * }}
56
+ * ...
57
+ * />
58
+ *
59
+ * 3. Custom picker options:
60
+ * <MediaPopup
61
+ * picker={...}
62
+ * pickerOptions={(accept) => ({
63
+ * mediaType: accept?.includes('image') ? 'photo' : 'video',
64
+ * quality: 0.9,
65
+ * allowsMultiple: true,
66
+ * // Add any other options your picker library supports
67
+ * })}
68
+ * ...
69
+ * />
70
+ *
71
+ * @param {Function} picker - REQUIRED: Your file picker function
72
+ * Should accept options and return a promise that resolves with an array of file objects
73
+ * Each file object should have: { uri, type/mimeType, fileName/name }
74
+ *
75
+ * @param {Function} pickerOptions - Optional: Function to generate picker options based on accept type
76
+ * Default: { mediaType: 'photo' | 'video' | 'mixed', quality: 0.8, allowsMultiple: true }
77
+ */
78
+ var FileUpload = function FileUpload(_ref) {
79
+ var loadMedia = _ref.loadMedia,
80
+ accept = _ref.accept,
81
+ title = _ref.title,
82
+ apiService = _ref.apiService,
83
+ onUploadStart = _ref.onUploadStart,
84
+ onUploadComplete = _ref.onUploadComplete,
85
+ onUploadError = _ref.onUploadError,
86
+ picker = _ref.picker,
87
+ pickerOptions = _ref.pickerOptions,
88
+ _ref$theme = _ref.theme,
89
+ theme = _ref$theme === void 0 ? _theme.defaultTheme : _ref$theme,
90
+ containerStyle = _ref.containerStyle,
91
+ buttonStyle = _ref.buttonStyle,
92
+ iconContainerStyle = _ref.iconContainerStyle,
93
+ titleStyle = _ref.titleStyle,
94
+ loadingStyle = _ref.loadingStyle;
95
+ var _useState = (0, _react.useState)(false),
96
+ _useState2 = _slicedToArray(_useState, 2),
97
+ isLoading = _useState2[0],
98
+ setISLoading = _useState2[1];
99
+ var _useState3 = (0, _react.useState)(0),
100
+ _useState4 = _slicedToArray(_useState3, 2),
101
+ uploadProgress = _useState4[0],
102
+ setUploadProgress = _useState4[1];
103
+
104
+ // Convert file picker result to File-like object for apiService
105
+ var convertToFile = function convertToFile(pickerResult) {
106
+ // Picker typically returns: { uri, type, fileName, fileSize, width, height }
107
+ // We need to create a File-like object that apiService.uploadMedia expects
108
+ // For React Native, we'll use the URI directly and let uploadMedia handle it
109
+
110
+ return {
111
+ uri: pickerResult.uri,
112
+ name: pickerResult.fileName || pickerResult.uri.split("/").pop() || "image.jpg",
113
+ type: pickerResult.type || pickerResult.mimeType || "image/jpeg",
114
+ // Keep original picker result for potential use
115
+ _pickerResult: pickerResult
116
+ };
117
+ };
118
+ var uploadFiles = /*#__PURE__*/function () {
119
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(fileList) {
120
+ var filesToUpload, uploadedUrls, _t;
121
+ return _regenerator().w(function (_context) {
122
+ while (1) switch (_context.p = _context.n) {
123
+ case 0:
124
+ if (onUploadStart) {
125
+ onUploadStart(fileList);
126
+ }
127
+ setISLoading(true);
128
+ setUploadProgress(0);
129
+ _context.p = 1;
130
+ // Convert picker results to File-like objects
131
+ filesToUpload = fileList.map(convertToFile); // Use the API service to upload files
132
+ // Note: uploadMedia will need to handle React Native file URIs
133
+ _context.n = 2;
134
+ return apiService.uploadMedia(filesToUpload, apiService.authKey);
135
+ case 2:
136
+ uploadedUrls = _context.v;
137
+ if (onUploadComplete) {
138
+ onUploadComplete(uploadedUrls);
139
+ }
140
+ setUploadProgress(0);
141
+ if (loadMedia) {
142
+ loadMedia();
143
+ }
144
+ _context.n = 4;
145
+ break;
146
+ case 3:
147
+ _context.p = 3;
148
+ _t = _context.v;
149
+ console.error("Upload error:", _t);
150
+ if (onUploadError) {
151
+ onUploadError(_t);
152
+ }
153
+ _reactNative.Alert.alert("Upload Error", _t.message || "Failed to upload file");
154
+ case 4:
155
+ _context.p = 4;
156
+ setISLoading(false);
157
+ return _context.f(4);
158
+ case 5:
159
+ return _context.a(2);
160
+ }
161
+ }, _callee, null, [[1, 3, 4, 5]]);
162
+ }));
163
+ return function uploadFiles(_x) {
164
+ return _ref2.apply(this, arguments);
165
+ };
166
+ }();
167
+ var handlePickFile = /*#__PURE__*/function () {
168
+ var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
169
+ var options, isImage, isVideo, result, assets, _error$message, _t2;
170
+ return _regenerator().w(function (_context2) {
171
+ while (1) switch (_context2.p = _context2.n) {
172
+ case 0:
173
+ if (picker) {
174
+ _context2.n = 1;
175
+ break;
176
+ }
177
+ _reactNative.Alert.alert("File Picker Not Configured", "Please provide a picker function prop. See FileUpload.native.jsx documentation for examples.", [{
178
+ text: "OK"
179
+ }]);
180
+ return _context2.a(2);
181
+ case 1:
182
+ _context2.p = 1;
183
+ // Generate picker options based on accept type
184
+
185
+ if (pickerOptions && typeof pickerOptions === "function") {
186
+ options = pickerOptions(accept);
187
+ } else {
188
+ // Default options
189
+ isImage = accept === null || accept === void 0 ? void 0 : accept.includes("image");
190
+ isVideo = accept === null || accept === void 0 ? void 0 : accept.includes("video");
191
+ options = {
192
+ mediaType: isImage ? "photo" : isVideo ? "video" : "mixed",
193
+ quality: 0.8,
194
+ allowsMultiple: true
195
+ };
196
+ }
197
+
198
+ // Call the picker function provided by the app
199
+ _context2.n = 2;
200
+ return picker(options);
201
+ case 2:
202
+ result = _context2.v;
203
+ // Handle different picker response formats
204
+ // react-native-image-picker: { assets: [...] }
205
+ // expo-image-picker: { assets: [...] }
206
+ // Custom: could be array directly or { assets: [...] }
207
+ assets = Array.isArray(result) ? result : (result === null || result === void 0 ? void 0 : result.assets) || result || [];
208
+ if (!(assets && assets.length > 0)) {
209
+ _context2.n = 3;
210
+ break;
211
+ }
212
+ _context2.n = 3;
213
+ return uploadFiles(assets);
214
+ case 3:
215
+ _context2.n = 6;
216
+ break;
217
+ case 4:
218
+ _context2.p = 4;
219
+ _t2 = _context2.v;
220
+ console.error("Error picking file:", _t2);
221
+ if (!(_t2.code === "E_PICKER_CANCELLED" || (_error$message = _t2.message) !== null && _error$message !== void 0 && _error$message.includes("cancel"))) {
222
+ _context2.n = 5;
223
+ break;
224
+ }
225
+ return _context2.a(2);
226
+ case 5:
227
+ _reactNative.Alert.alert("Error", _t2.message || "Failed to pick file");
228
+ case 6:
229
+ return _context2.a(2);
230
+ }
231
+ }, _callee2, null, [[1, 4]]);
232
+ }));
233
+ return function handlePickFile() {
234
+ return _ref3.apply(this, arguments);
235
+ };
236
+ }();
237
+ if (isLoading) {
238
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
239
+ style: [styles.loadingContainer, {
240
+ backgroundColor: theme.colors.loadingBackground,
241
+ borderRadius: theme.radius.md
242
+ }, loadingStyle],
243
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
244
+ size: "small",
245
+ color: theme.colors.primary
246
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
247
+ style: [styles.loadingText, {
248
+ color: theme.colors.loadingText,
249
+ marginTop: theme.spacing.sm
250
+ }],
251
+ children: "Uploading..."
252
+ })]
253
+ });
254
+ }
255
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
256
+ style: [styles.container, containerStyle],
257
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.TouchableOpacity, {
258
+ onPress: handlePickFile,
259
+ style: [styles.button, {
260
+ borderColor: theme.colors.uploadBorder,
261
+ backgroundColor: theme.colors.uploadBackground,
262
+ borderRadius: theme.radius.md
263
+ }, buttonStyle],
264
+ disabled: isLoading,
265
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
266
+ style: [styles.iconContainer, {
267
+ backgroundColor: theme.colors.uploadIconBackground,
268
+ borderRadius: theme.radius.xl,
269
+ marginBottom: theme.spacing.sm,
270
+ padding: theme.spacing.md
271
+ }, iconContainerStyle],
272
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icons.CameraIcon, {})
273
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
274
+ style: [styles.title, {
275
+ color: theme.colors.uploadText,
276
+ marginTop: theme.spacing.sm,
277
+ fontSize: theme.typography.caption.fontSize
278
+ }, titleStyle],
279
+ children: title
280
+ })]
281
+ })
282
+ });
283
+ };
284
+ var styles = _reactNative.StyleSheet.create({
285
+ container: {
286
+ width: "100%",
287
+ height: 160
288
+ },
289
+ button: {
290
+ width: "100%",
291
+ height: "100%",
292
+ flexDirection: "column",
293
+ justifyContent: "center",
294
+ alignItems: "center",
295
+ borderWidth: 1,
296
+ borderStyle: "dashed"
297
+ // Colors applied via theme
298
+ },
299
+ iconContainer: {
300
+ // Colors and spacing applied via theme
301
+ },
302
+ title: {
303
+ // Colors and typography applied via theme
304
+ },
305
+ loadingContainer: {
306
+ width: "100%",
307
+ height: 160,
308
+ justifyContent: "center",
309
+ alignItems: "center"
310
+ // Colors applied via theme
311
+ },
312
+ loadingText: {
313
+ // Colors applied via theme
314
+ }
315
+ });
316
+ var _default = exports.default = FileUpload;
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.CloseIcon = exports.CameraIcon = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _jsxRuntime = require("react/jsx-runtime");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ // Note: For better icons, you can use react-native-svg or react-native-vector-icons
12
+ // This is a simple implementation using Text/View
13
+
14
+ var CloseIcon = exports.CloseIcon = function CloseIcon(_ref) {
15
+ var _ref$size = _ref.size,
16
+ size = _ref$size === void 0 ? 32 : _ref$size,
17
+ _ref$color = _ref.color,
18
+ color = _ref$color === void 0 ? '#000000' : _ref$color;
19
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
20
+ style: [styles.closeIcon, {
21
+ width: size,
22
+ height: size
23
+ }],
24
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
25
+ style: [styles.closeIconText, {
26
+ color: color,
27
+ fontSize: size * 0.6
28
+ }],
29
+ children: "\u2715"
30
+ })
31
+ });
32
+ };
33
+ var CameraIcon = exports.CameraIcon = function CameraIcon() {
34
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
35
+ style: styles.cameraIcon,
36
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
37
+ style: styles.cameraIconText,
38
+ children: "\uD83D\uDCF7"
39
+ })
40
+ });
41
+ };
42
+ var styles = _reactNative.StyleSheet.create({
43
+ closeIcon: {
44
+ justifyContent: 'center',
45
+ alignItems: 'center'
46
+ },
47
+ closeIconText: {
48
+ fontWeight: 'bold'
49
+ },
50
+ cameraIcon: {
51
+ width: 22,
52
+ height: 18,
53
+ justifyContent: 'center',
54
+ alignItems: 'center'
55
+ },
56
+ cameraIconText: {
57
+ fontSize: 18
58
+ }
59
+ });
@@ -0,0 +1,52 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _reactNative = require("react-native");
9
+ var _jsxRuntime = require("react/jsx-runtime");
10
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
11
+ var _Dimensions$get = _reactNative.Dimensions.get('window'),
12
+ SCREEN_WIDTH = _Dimensions$get.width;
13
+ var NUM_COLUMNS = 3;
14
+ var ITEM_MARGIN = 8;
15
+ var ITEM_SIZE = (SCREEN_WIDTH - 40 - ITEM_MARGIN * (NUM_COLUMNS - 1) * 2) / NUM_COLUMNS;
16
+ var ImagesSkeleton = function ImagesSkeleton(_ref) {
17
+ var _ref$per_page = _ref.per_page,
18
+ per_page = _ref$per_page === void 0 ? 30 : _ref$per_page;
19
+ var skeletonItems = [];
20
+ for (var i = 0; i < per_page; i++) {
21
+ skeletonItems.push(/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
22
+ style: [styles.skeletonItem, {
23
+ width: ITEM_SIZE,
24
+ height: ITEM_SIZE,
25
+ margin: ITEM_MARGIN
26
+ }],
27
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.ActivityIndicator, {
28
+ size: "small",
29
+ color: "#3B3269"
30
+ })
31
+ }, i));
32
+ }
33
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
34
+ style: styles.container,
35
+ children: skeletonItems
36
+ });
37
+ };
38
+ var styles = _reactNative.StyleSheet.create({
39
+ container: {
40
+ flexDirection: 'row',
41
+ flexWrap: 'wrap',
42
+ padding: 4
43
+ },
44
+ skeletonItem: {
45
+ backgroundColor: '#E5E5E5',
46
+ borderRadius: 8,
47
+ justifyContent: 'center',
48
+ alignItems: 'center',
49
+ opacity: 0.3
50
+ }
51
+ });
52
+ var _default = exports.default = ImagesSkeleton;