@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,237 @@
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 _FileUpload = _interopRequireDefault(require("./FileUpload.native"));
11
+ var _ImagesSkeleton = _interopRequireDefault(require("./ImagesSkeleton.native"));
12
+ var _Pagination = _interopRequireDefault(require("./Pagination.native"));
13
+ var _theme = require("./theme");
14
+ var _jsxRuntime = require("react/jsx-runtime");
15
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
16
+ 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 _t2 in e) "default" !== _t2 && {}.hasOwnProperty.call(e, _t2) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t2)) && (i.get || i.set) ? o(f, _t2, i) : f[_t2] = e[_t2]); return f; })(e, t); }
17
+ function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
18
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
19
+ function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
20
+ function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
21
+ 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 }; })(); }
22
+ 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); }
23
+ 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); }
24
+ 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); }); }; }
25
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
26
+ 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."); }
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; } }
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; }
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; } }
30
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
31
+ var _Dimensions$get = _reactNative.Dimensions.get('window'),
32
+ SCREEN_WIDTH = _Dimensions$get.width;
33
+ var NUM_COLUMNS = 3;
34
+ var ITEM_MARGIN = 8;
35
+ var ITEM_SIZE = (SCREEN_WIDTH - 40 - ITEM_MARGIN * (NUM_COLUMNS - 1) * 2) / NUM_COLUMNS; // 40 = padding, adjust for margins
36
+
37
+ 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'];
38
+ var ImagesGallery = function ImagesGallery(_ref) {
39
+ var update_data = _ref.update_data,
40
+ closePopup = _ref.closePopup,
41
+ apiService = _ref.apiService,
42
+ onError = _ref.onError,
43
+ picker = _ref.picker,
44
+ pickerOptions = _ref.pickerOptions,
45
+ _ref$theme = _ref.theme,
46
+ theme = _ref$theme === void 0 ? _theme.defaultTheme : _ref$theme,
47
+ containerStyle = _ref.containerStyle,
48
+ gridStyle = _ref.gridStyle,
49
+ imageItemStyle = _ref.imageItemStyle,
50
+ paginationContainerStyle = _ref.paginationContainerStyle;
51
+ var _useState = (0, _react.useState)([]),
52
+ _useState2 = _slicedToArray(_useState, 2),
53
+ images = _useState2[0],
54
+ setImages = _useState2[1];
55
+ var _useState3 = (0, _react.useState)(0),
56
+ _useState4 = _slicedToArray(_useState3, 2),
57
+ total_count = _useState4[0],
58
+ setTotalCount = _useState4[1];
59
+ var _useState5 = (0, _react.useState)(1),
60
+ _useState6 = _slicedToArray(_useState5, 2),
61
+ currentPage = _useState6[0],
62
+ setCurrentPage = _useState6[1];
63
+ var _useState7 = (0, _react.useState)(false),
64
+ _useState8 = _slicedToArray(_useState7, 2),
65
+ isLoading = _useState8[0],
66
+ setISLoading = _useState8[1];
67
+
68
+ // Fetch images
69
+ (0, _react.useEffect)(function () {
70
+ loadMedia();
71
+ }, []);
72
+ var loadMedia = /*#__PURE__*/function () {
73
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
74
+ var page_number,
75
+ _response$data,
76
+ _response$data2,
77
+ response,
78
+ mediaData,
79
+ count,
80
+ _args = arguments,
81
+ _t;
82
+ return _regenerator().w(function (_context) {
83
+ while (1) switch (_context.p = _context.n) {
84
+ case 0:
85
+ page_number = _args.length > 0 && _args[0] !== undefined ? _args[0] : 1;
86
+ _context.p = 1;
87
+ _context.n = 2;
88
+ return apiService.fetchMedia({
89
+ mimeTypes: IMAGE_MIME_TYPES,
90
+ page: page_number,
91
+ setISLoading: setISLoading,
92
+ isLoading: isLoading
93
+ });
94
+ case 2:
95
+ response = _context.v;
96
+ // Handle different response formats
97
+ 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 || [];
98
+ 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;
99
+ setImages(Array.isArray(mediaData) ? mediaData : []);
100
+ setTotalCount(count);
101
+ setCurrentPage(page_number);
102
+ _context.n = 4;
103
+ break;
104
+ case 3:
105
+ _context.p = 3;
106
+ _t = _context.v;
107
+ console.error('Error loading media:', _t);
108
+ if (onError) {
109
+ onError(_t);
110
+ }
111
+ case 4:
112
+ return _context.a(2);
113
+ }
114
+ }, _callee, null, [[1, 3]]);
115
+ }));
116
+ return function loadMedia() {
117
+ return _ref2.apply(this, arguments);
118
+ };
119
+ }();
120
+ var handleImageClick = function handleImageClick(image) {
121
+ if (update_data) {
122
+ update_data(image.url || image);
123
+ }
124
+ if (closePopup) {
125
+ closePopup();
126
+ }
127
+ };
128
+ var renderItem = function renderItem(_ref3) {
129
+ var item = _ref3.item,
130
+ index = _ref3.index;
131
+ // First item is the upload button
132
+ if (index === 0) {
133
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
134
+ style: [styles.uploadContainer, {
135
+ width: ITEM_SIZE,
136
+ height: ITEM_SIZE
137
+ }],
138
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_FileUpload.default, {
139
+ loadMedia: loadMedia,
140
+ accept: "image/*",
141
+ title: "Add Image",
142
+ apiService: apiService,
143
+ onUploadError: onError,
144
+ picker: picker,
145
+ pickerOptions: pickerOptions,
146
+ theme: theme
147
+ })
148
+ });
149
+ }
150
+ var image = images[index - 1];
151
+ var imageUrl = typeof image === 'string' ? image : image.url;
152
+ var imageKey = image.id || image.url || index;
153
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
154
+ onPress: function onPress() {
155
+ return handleImageClick(image);
156
+ },
157
+ style: [styles.imageItem, {
158
+ width: ITEM_SIZE,
159
+ height: ITEM_SIZE,
160
+ backgroundColor: theme.colors.itemBackground,
161
+ shadowColor: theme.colors.itemShadow
162
+ }, imageItemStyle],
163
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Image, {
164
+ source: {
165
+ uri: imageUrl
166
+ },
167
+ style: styles.image,
168
+ resizeMode: "cover"
169
+ })
170
+ });
171
+ };
172
+ var data = isLoading ? [] : [{
173
+ type: 'upload'
174
+ }].concat(_toConsumableArray(images));
175
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
176
+ style: [styles.container, containerStyle],
177
+ children: isLoading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ImagesSkeleton.default, {}) : /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.FlatList, {
178
+ data: data,
179
+ renderItem: renderItem,
180
+ keyExtractor: function keyExtractor(item, index) {
181
+ if (index === 0) return 'upload';
182
+ var image = images[index - 1];
183
+ return image.id || image.url || "image-".concat(index);
184
+ },
185
+ numColumns: NUM_COLUMNS,
186
+ contentContainerStyle: [styles.grid, gridStyle],
187
+ showsVerticalScrollIndicator: false,
188
+ ListFooterComponent: total_count > 0 ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
189
+ style: [styles.paginationContainer, {
190
+ backgroundColor: theme.colors.paginationBackground,
191
+ paddingVertical: theme.spacing.lg,
192
+ paddingHorizontal: theme.spacing.sm,
193
+ marginTop: theme.spacing.sm
194
+ }, paginationContainerStyle],
195
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Pagination.default, {
196
+ nextPage: function nextPage(value) {
197
+ return loadMedia(value);
198
+ },
199
+ pageCount: Math.ceil(total_count / 30),
200
+ current_page: currentPage,
201
+ theme: theme
202
+ })
203
+ }) : null
204
+ })
205
+ });
206
+ };
207
+ var styles = _reactNative.StyleSheet.create({
208
+ container: {
209
+ flex: 1
210
+ },
211
+ grid: {
212
+ padding: 4
213
+ },
214
+ uploadContainer: {
215
+ margin: ITEM_MARGIN
216
+ },
217
+ imageItem: {
218
+ margin: ITEM_MARGIN,
219
+ borderRadius: 8,
220
+ overflow: 'hidden',
221
+ shadowOffset: {
222
+ width: 0,
223
+ height: 2
224
+ },
225
+ shadowOpacity: 0.1,
226
+ shadowRadius: 3.84,
227
+ elevation: 5
228
+ },
229
+ image: {
230
+ width: '100%',
231
+ height: '100%'
232
+ },
233
+ paginationContainer: {
234
+ // Styles applied via theme
235
+ }
236
+ });
237
+ var _default = exports.default = ImagesGallery;
@@ -0,0 +1,177 @@
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 _MediaTab = _interopRequireDefault(require("./MediaTab.native"));
10
+ var _Icons = require("./Icons.native");
11
+ var _theme = require("./theme");
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
14
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
15
+ 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."); }
16
+ 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; } }
17
+ 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; }
18
+ 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; } }
19
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
20
+ var _Dimensions$get = _reactNative.Dimensions.get('window'),
21
+ SCREEN_HEIGHT = _Dimensions$get.height;
22
+ var MediaPopup = function MediaPopup(_ref) {
23
+ var isOpen = _ref.isOpen,
24
+ onClose = _ref.onClose,
25
+ onSelect = _ref.onSelect,
26
+ currentData = _ref.currentData,
27
+ _ref$options = _ref.options,
28
+ options = _ref$options === void 0 ? ['image'] : _ref$options,
29
+ apiService = _ref.apiService,
30
+ onError = _ref.onError,
31
+ _ref$title = _ref.title,
32
+ title = _ref$title === void 0 ? 'Media Gallery' : _ref$title,
33
+ picker = _ref.picker,
34
+ pickerOptions = _ref.pickerOptions,
35
+ theme = _ref.theme,
36
+ overlayStyle = _ref.overlayStyle,
37
+ containerStyle = _ref.containerStyle,
38
+ headerStyle = _ref.headerStyle,
39
+ titleStyle = _ref.titleStyle,
40
+ closeButtonStyle = _ref.closeButtonStyle,
41
+ closeButtonTextStyle = _ref.closeButtonTextStyle,
42
+ bottomSheetHeight = _ref.bottomSheetHeight;
43
+ var currentTheme = _react.default.useMemo(function () {
44
+ return (0, _theme.createTheme)(theme);
45
+ }, [theme]);
46
+ var sheetHeight = bottomSheetHeight || currentTheme.bottomSheetHeight || 0.9;
47
+ var _React$useState = _react.default.useState(new _reactNative.Animated.Value(SCREEN_HEIGHT)),
48
+ _React$useState2 = _slicedToArray(_React$useState, 1),
49
+ slideAnim = _React$useState2[0];
50
+ _react.default.useEffect(function () {
51
+ if (isOpen) {
52
+ _reactNative.Animated.spring(slideAnim, {
53
+ toValue: 0,
54
+ useNativeDriver: true,
55
+ tension: 65,
56
+ friction: 11
57
+ }).start();
58
+ } else {
59
+ _reactNative.Animated.timing(slideAnim, {
60
+ toValue: SCREEN_HEIGHT,
61
+ duration: 250,
62
+ useNativeDriver: true
63
+ }).start();
64
+ }
65
+ }, [isOpen]);
66
+ var handleUpdate = function handleUpdate(data) {
67
+ if (onSelect) {
68
+ onSelect(data);
69
+ }
70
+ };
71
+ var handleClose = function handleClose() {
72
+ if (onClose) {
73
+ onClose();
74
+ }
75
+ };
76
+ if (!isOpen) return null;
77
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Modal, {
78
+ visible: isOpen,
79
+ transparent: true,
80
+ animationType: "none",
81
+ onRequestClose: handleClose,
82
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableWithoutFeedback, {
83
+ onPress: handleClose,
84
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
85
+ style: [styles.overlay, {
86
+ backgroundColor: currentTheme.colors.overlay
87
+ }, overlayStyle],
88
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableWithoutFeedback, {
89
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.Animated.View, {
90
+ style: [styles.container, {
91
+ backgroundColor: currentTheme.colors.background,
92
+ borderTopLeftRadius: currentTheme.radius.xxl,
93
+ borderTopRightRadius: currentTheme.radius.xxl,
94
+ maxHeight: SCREEN_HEIGHT * sheetHeight,
95
+ padding: currentTheme.spacing.xl
96
+ }, containerStyle, {
97
+ transform: [{
98
+ translateY: slideAnim
99
+ }]
100
+ }],
101
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
102
+ style: [styles.header, {
103
+ borderBottomColor: currentTheme.colors.border,
104
+ marginBottom: currentTheme.spacing.lg,
105
+ paddingBottom: currentTheme.spacing.md
106
+ }, headerStyle],
107
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
108
+ style: [styles.title, {
109
+ fontSize: currentTheme.typography.title.fontSize,
110
+ fontWeight: currentTheme.typography.title.fontWeight,
111
+ color: currentTheme.colors.text
112
+ }, titleStyle],
113
+ children: title
114
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.TouchableOpacity, {
115
+ onPress: handleClose,
116
+ style: [styles.closeButton, closeButtonStyle],
117
+ hitSlop: {
118
+ top: 10,
119
+ bottom: 10,
120
+ left: 10,
121
+ right: 10
122
+ },
123
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_Icons.CloseIcon, {
124
+ size: 24,
125
+ color: currentTheme.colors.text
126
+ })
127
+ })]
128
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_MediaTab.default, {
129
+ imagePopup: isOpen,
130
+ update_data: handleUpdate,
131
+ current_data: currentData,
132
+ closePopup: handleClose,
133
+ options: options,
134
+ apiService: apiService,
135
+ onError: onError,
136
+ picker: picker,
137
+ pickerOptions: pickerOptions,
138
+ theme: currentTheme
139
+ })]
140
+ })
141
+ })
142
+ })
143
+ })
144
+ });
145
+ };
146
+ var styles = _reactNative.StyleSheet.create({
147
+ overlay: {
148
+ flex: 1,
149
+ justifyContent: 'flex-end'
150
+ },
151
+ container: {
152
+ minHeight: 200,
153
+ shadowColor: '#000',
154
+ shadowOffset: {
155
+ width: 0,
156
+ height: -2
157
+ },
158
+ shadowOpacity: 0.25,
159
+ shadowRadius: 3.84,
160
+ elevation: 5
161
+ },
162
+ header: {
163
+ flexDirection: 'row',
164
+ alignItems: 'center',
165
+ justifyContent: 'space-between',
166
+ borderBottomWidth: 1
167
+ },
168
+ title: {
169
+ flex: 1
170
+ },
171
+ closeButton: {
172
+ padding: 8,
173
+ borderRadius: 20,
174
+ marginLeft: 12
175
+ }
176
+ });
177
+ var _default = exports.default = MediaPopup;
@@ -0,0 +1,201 @@
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 _MediaGallery = _interopRequireDefault(require("./MediaGallery.native"));
11
+ var _VideosGallery = _interopRequireDefault(require("./VideosGallery.native"));
12
+ var _theme = require("./theme");
13
+ var _jsxRuntime = require("react/jsx-runtime");
14
+ function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
15
+ 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 _t in e) "default" !== _t && {}.hasOwnProperty.call(e, _t) && ((i = (o = Object.defineProperty) && Object.getOwnPropertyDescriptor(e, _t)) && (i.get || i.set) ? o(f, _t, i) : f[_t] = e[_t]); return f; })(e, t); }
16
+ function _slicedToArray(r, e) { return _arrayWithHoles(r) || _iterableToArrayLimit(r, e) || _unsupportedIterableToArray(r, e) || _nonIterableRest(); }
17
+ 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."); }
18
+ 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; } }
19
+ 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; }
20
+ 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; } }
21
+ function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
22
+ var MediaTab = function MediaTab(_ref) {
23
+ var imagePopup = _ref.imagePopup,
24
+ current_data = _ref.current_data,
25
+ update_data = _ref.update_data,
26
+ closePopup = _ref.closePopup,
27
+ options = _ref.options,
28
+ apiService = _ref.apiService,
29
+ onError = _ref.onError,
30
+ picker = _ref.picker,
31
+ pickerOptions = _ref.pickerOptions,
32
+ _ref$theme = _ref.theme,
33
+ theme = _ref$theme === void 0 ? _theme.defaultTheme : _ref$theme,
34
+ containerStyle = _ref.containerStyle,
35
+ tabListStyle = _ref.tabListStyle,
36
+ tabButtonStyle = _ref.tabButtonStyle,
37
+ tabButtonActiveStyle = _ref.tabButtonActiveStyle,
38
+ tabButtonInactiveStyle = _ref.tabButtonInactiveStyle,
39
+ tabButtonTextStyle = _ref.tabButtonTextStyle,
40
+ tabButtonTextActiveStyle = _ref.tabButtonTextActiveStyle,
41
+ tabButtonTextInactiveStyle = _ref.tabButtonTextInactiveStyle,
42
+ tabIndicatorStyle = _ref.tabIndicatorStyle,
43
+ tabPanelStyle = _ref.tabPanelStyle;
44
+ // Build a stable list of enabled tabs in order
45
+ var availableTabs = (0, _react.useMemo)(function () {
46
+ var tabs = [];
47
+ if (options !== null && options !== void 0 && options.includes('image')) tabs.push('image');
48
+ if (options !== null && options !== void 0 && options.includes('video')) tabs.push('video');
49
+ if (options !== null && options !== void 0 && options.includes('file')) tabs.push('file');
50
+ return tabs;
51
+ }, [options]);
52
+ var _useState = (0, _react.useState)(0),
53
+ _useState2 = _slicedToArray(_useState, 2),
54
+ selectedIndex = _useState2[0],
55
+ setSelectedIndex = _useState2[1];
56
+
57
+ // Guard: if no options passed, render nothing
58
+ if (!availableTabs.length) {
59
+ return null;
60
+ }
61
+ var renderTabLabel = function renderTabLabel(type) {
62
+ if (type === 'image') return 'Images';
63
+ if (type === 'video') return 'Videos';
64
+ if (type === 'file') return 'Files';
65
+ return type;
66
+ };
67
+ var renderPanel = function renderPanel(type) {
68
+ if (type === 'image') {
69
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_MediaGallery.default, {
70
+ imagePopup: imagePopup,
71
+ update_data: update_data,
72
+ current_data: current_data,
73
+ closePopup: closePopup,
74
+ apiService: apiService,
75
+ onError: onError,
76
+ picker: picker,
77
+ pickerOptions: pickerOptions
78
+ });
79
+ }
80
+ if (type === 'video') {
81
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_VideosGallery.default, {
82
+ imagePopup: imagePopup,
83
+ update_data: update_data,
84
+ current_data: current_data,
85
+ closePopup: closePopup,
86
+ apiService: apiService,
87
+ onError: onError,
88
+ picker: picker,
89
+ pickerOptions: pickerOptions,
90
+ theme: theme
91
+ });
92
+ }
93
+ if (type === 'file') {
94
+ // Reuse ImagesGallery for files as in original implementation
95
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_MediaGallery.default, {
96
+ imagePopup: imagePopup,
97
+ update_data: update_data,
98
+ current_data: current_data,
99
+ closePopup: closePopup,
100
+ apiService: apiService,
101
+ onError: onError,
102
+ picker: picker,
103
+ pickerOptions: pickerOptions
104
+ });
105
+ }
106
+ return null;
107
+ };
108
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.View, {
109
+ style: [styles.container, containerStyle],
110
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
111
+ style: [styles.tabList, {
112
+ backgroundColor: theme.colors.tabBackground,
113
+ borderBottomColor: theme.colors.border,
114
+ paddingHorizontal: theme.spacing.xs
115
+ }, tabListStyle],
116
+ children: availableTabs.map(function (type, index) {
117
+ var isSelected = index === selectedIndex;
118
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_reactNative.TouchableOpacity, {
119
+ onPress: function onPress() {
120
+ return setSelectedIndex(index);
121
+ },
122
+ style: [styles.tabButton, {
123
+ paddingVertical: theme.spacing.md,
124
+ paddingHorizontal: theme.spacing.lg
125
+ }, tabButtonStyle, isSelected ? [styles.tabButtonActive, tabButtonActiveStyle] : [styles.tabButtonInactive, tabButtonInactiveStyle]],
126
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.Text, {
127
+ style: [styles.tabButtonText, {
128
+ fontSize: theme.typography.body.fontSize,
129
+ fontWeight: theme.typography.body.fontWeight
130
+ }, isSelected ? [styles.tabButtonTextActive, {
131
+ color: theme.colors.tabActive
132
+ }, tabButtonTextActiveStyle] : [styles.tabButtonTextInactive, {
133
+ color: theme.colors.tabInactive
134
+ }, tabButtonTextInactiveStyle], tabButtonTextStyle],
135
+ children: renderTabLabel(type)
136
+ }), isSelected && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
137
+ style: [styles.tabIndicator, {
138
+ backgroundColor: theme.colors.tabIndicator
139
+ }, tabIndicatorStyle]
140
+ })]
141
+ }, type);
142
+ })
143
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
144
+ style: [styles.tabPanel, tabPanelStyle],
145
+ children: availableTabs.map(function (type, index) {
146
+ var isSelected = index === selectedIndex;
147
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactNative.View, {
148
+ style: isSelected ? styles.panelVisible : styles.panelHidden,
149
+ children: isSelected && renderPanel(type)
150
+ }, type);
151
+ })
152
+ })]
153
+ });
154
+ };
155
+ var styles = _reactNative.StyleSheet.create({
156
+ container: {
157
+ flex: 1
158
+ },
159
+ tabList: {
160
+ flexDirection: 'row',
161
+ borderBottomWidth: 2
162
+ },
163
+ tabButton: {
164
+ flex: 1,
165
+ alignItems: 'center',
166
+ justifyContent: 'center',
167
+ position: 'relative'
168
+ },
169
+ tabButtonActive: {
170
+ // Active state styling applied via theme
171
+ },
172
+ tabButtonInactive: {
173
+ // Inactive state styling applied via theme
174
+ },
175
+ tabButtonText: {
176
+ // Base text styling applied via theme
177
+ },
178
+ tabButtonTextActive: {
179
+ // Active text color applied via theme
180
+ },
181
+ tabButtonTextInactive: {
182
+ // Inactive text color applied via theme
183
+ },
184
+ tabIndicator: {
185
+ position: 'absolute',
186
+ bottom: -2,
187
+ left: 0,
188
+ right: 0,
189
+ height: 2
190
+ },
191
+ tabPanel: {
192
+ flex: 1
193
+ },
194
+ panelVisible: {
195
+ flex: 1
196
+ },
197
+ panelHidden: {
198
+ display: 'none'
199
+ }
200
+ });
201
+ var _default = exports.default = MediaTab;