@tradly/asset 1.0.21 → 1.0.23
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/components/FilesGallery.js +13 -0
- package/dist/core/FileTypes.js +11 -0
- package/dist/esm/components/FilesGallery.js +1 -0
- package/dist/esm/core/FileTypes.js +6 -0
- package/dist/esm/native/FilesGallery.native.js +288 -0
- package/dist/esm/native/MediaGallery.native.js +1 -1
- package/dist/esm/native/MediaTab.native.js +3 -2
- package/dist/esm/native/VideosGallery.native.js +23 -23
- package/dist/esm/web/FilesGallery.web.js +173 -0
- package/dist/esm/web/MediaGallery.web.js +12 -12
- package/dist/esm/web/MediaTab.web.js +26 -26
- package/dist/esm/web/VideosGallery.web.js +11 -11
- package/dist/native/FilesGallery.native.js +297 -0
- package/dist/native/MediaGallery.native.js +2 -2
- package/dist/native/MediaTab.native.js +3 -2
- package/dist/native/VideosGallery.native.js +18 -18
- package/dist/web/FilesGallery.web.js +182 -0
- package/dist/web/MediaGallery.web.js +9 -9
- package/dist/web/MediaTab.web.js +23 -23
- package/dist/web/VideosGallery.web.js +8 -8
- package/package.json +1 -1
|
@@ -0,0 +1,173 @@
|
|
|
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 { FILE_MIME_TYPES } from "../core/FileTypes";
|
|
16
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
17
|
+
var FilesGallery = function FilesGallery(_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
|
+
fileItemClassName = _ref.fileItemClassName,
|
|
25
|
+
paginationContainerClassName = _ref.paginationContainerClassName;
|
|
26
|
+
var _useState = useState([]),
|
|
27
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
28
|
+
files = _useState2[0],
|
|
29
|
+
setFiles = _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 files
|
|
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: FILE_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
|
+
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 || [];
|
|
73
|
+
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;
|
|
74
|
+
setFiles(Array.isArray(mediaData) ? mediaData : []);
|
|
75
|
+
setTotalCount(count);
|
|
76
|
+
setCurrentPage(page_number);
|
|
77
|
+
_context.n = 4;
|
|
78
|
+
break;
|
|
79
|
+
case 3:
|
|
80
|
+
_context.p = 3;
|
|
81
|
+
_t = _context.v;
|
|
82
|
+
console.error("Error loading files:", _t);
|
|
83
|
+
if (onError) {
|
|
84
|
+
onError(_t);
|
|
85
|
+
}
|
|
86
|
+
case 4:
|
|
87
|
+
return _context.a(2);
|
|
88
|
+
}
|
|
89
|
+
}, _callee, null, [[1, 3]]);
|
|
90
|
+
}));
|
|
91
|
+
return function loadMedia() {
|
|
92
|
+
return _ref2.apply(this, arguments);
|
|
93
|
+
};
|
|
94
|
+
}();
|
|
95
|
+
var handleFileClick = function handleFileClick(file) {
|
|
96
|
+
if (update_data) {
|
|
97
|
+
update_data(file.url || file);
|
|
98
|
+
}
|
|
99
|
+
if (closePopup) {
|
|
100
|
+
closePopup();
|
|
101
|
+
}
|
|
102
|
+
};
|
|
103
|
+
|
|
104
|
+
// Get file icon based on mime type
|
|
105
|
+
var getFileIcon = function getFileIcon(mimeType) {
|
|
106
|
+
if (!mimeType) return "📄";
|
|
107
|
+
if (mimeType.includes("pdf")) return "📕";
|
|
108
|
+
if (mimeType.includes("word") || mimeType.includes("document")) return "📘";
|
|
109
|
+
if (mimeType.includes("excel") || mimeType.includes("spreadsheet")) return "📗";
|
|
110
|
+
if (mimeType.includes("powerpoint") || mimeType.includes("presentation")) return "📙";
|
|
111
|
+
if (mimeType.includes("zip") || mimeType.includes("rar")) return "📦";
|
|
112
|
+
if (mimeType.includes("audio")) return "🎵";
|
|
113
|
+
if (mimeType.includes("text")) return "📝";
|
|
114
|
+
return "📄";
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// Get file extension from name or URL
|
|
118
|
+
var getFileExtension = function getFileExtension(file) {
|
|
119
|
+
var fileName = file.name || file.url || "";
|
|
120
|
+
var parts = fileName.split(".");
|
|
121
|
+
return parts.length > 1 ? parts[parts.length - 1].toUpperCase() : "";
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
// Default classes with customization support
|
|
125
|
+
var defaultContainerClass = "h-full flex flex-col justify-between";
|
|
126
|
+
var defaultGridClass = "grid grid-cols-[repeat(auto-fill,minmax(calc(160px),1fr))] gap-5";
|
|
127
|
+
var defaultFileItemClass = "cursor-pointer w-full h-40 flex flex-col items-center justify-center p-4 overflow-hidden bg-white rounded-md shadow-md hover:shadow-lg transition-shadow border border-gray-200";
|
|
128
|
+
var defaultPaginationContainerClass = "mb-4 bg-gray-100/90 p-4 sticky bottom-0";
|
|
129
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
130
|
+
className: className || defaultContainerClass,
|
|
131
|
+
children: [/*#__PURE__*/_jsxs("div", {
|
|
132
|
+
className: gridClassName || defaultGridClass,
|
|
133
|
+
children: [/*#__PURE__*/_jsx(FileUpload, {
|
|
134
|
+
loadMedia: loadMedia,
|
|
135
|
+
accept: "file/*",
|
|
136
|
+
title: "Add File",
|
|
137
|
+
apiService: apiService,
|
|
138
|
+
onUploadError: onError
|
|
139
|
+
}), isLoading ? /*#__PURE__*/_jsx(ImagesSkeleton, {}) : files === null || files === void 0 ? void 0 : files.map(function (file, index) {
|
|
140
|
+
var fileUrl = typeof file === "string" ? file : file.url;
|
|
141
|
+
var fileKey = file.id || file.url || index;
|
|
142
|
+
var mimeType = file.mime_type || file.type || "";
|
|
143
|
+
var fileName = file.name || (fileUrl === null || fileUrl === void 0 ? void 0 : fileUrl.split("/").pop()) || "File";
|
|
144
|
+
return /*#__PURE__*/_jsxs("div", {
|
|
145
|
+
onClick: function onClick() {
|
|
146
|
+
return handleFileClick(file);
|
|
147
|
+
},
|
|
148
|
+
className: fileItemClassName || defaultFileItemClass,
|
|
149
|
+
children: [/*#__PURE__*/_jsx("div", {
|
|
150
|
+
className: "text-4xl mb-2",
|
|
151
|
+
children: getFileIcon(mimeType)
|
|
152
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
153
|
+
className: "text-xs font-medium text-center text-gray-800 mb-1 line-clamp-2",
|
|
154
|
+
children: fileName
|
|
155
|
+
}), getFileExtension(file) && /*#__PURE__*/_jsx("div", {
|
|
156
|
+
className: "text-xs text-gray-500",
|
|
157
|
+
children: getFileExtension(file)
|
|
158
|
+
})]
|
|
159
|
+
}, fileKey);
|
|
160
|
+
})]
|
|
161
|
+
}), /*#__PURE__*/_jsx("div", {
|
|
162
|
+
className: paginationContainerClassName || defaultPaginationContainerClass,
|
|
163
|
+
children: total_count > 0 && /*#__PURE__*/_jsx(Pagination, {
|
|
164
|
+
nextPage: function nextPage(value) {
|
|
165
|
+
return loadMedia(value);
|
|
166
|
+
},
|
|
167
|
+
pageCount: Math.ceil(total_count / 30),
|
|
168
|
+
current_page: currentPage
|
|
169
|
+
})
|
|
170
|
+
})]
|
|
171
|
+
});
|
|
172
|
+
};
|
|
173
|
+
export default FilesGallery;
|
|
@@ -8,12 +8,12 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
8
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
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
10
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
11
|
-
import React, { useState, useEffect } from
|
|
12
|
-
import FileUpload from
|
|
13
|
-
import ImagesSkeleton from
|
|
14
|
-
import Pagination from
|
|
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 { IMAGE_MIME_TYPES } from "../core/FileTypes";
|
|
15
16
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
16
|
-
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'];
|
|
17
17
|
var ImagesGallery = function ImagesGallery(_ref) {
|
|
18
18
|
var update_data = _ref.update_data,
|
|
19
19
|
closePopup = _ref.closePopup,
|
|
@@ -80,7 +80,7 @@ var ImagesGallery = function ImagesGallery(_ref) {
|
|
|
80
80
|
case 3:
|
|
81
81
|
_context.p = 3;
|
|
82
82
|
_t = _context.v;
|
|
83
|
-
console.error(
|
|
83
|
+
console.error("Error loading media:", _t);
|
|
84
84
|
if (onError) {
|
|
85
85
|
onError(_t);
|
|
86
86
|
}
|
|
@@ -103,10 +103,10 @@ var ImagesGallery = function ImagesGallery(_ref) {
|
|
|
103
103
|
};
|
|
104
104
|
|
|
105
105
|
// Default classes with customization support
|
|
106
|
-
var defaultContainerClass =
|
|
107
|
-
var defaultGridClass =
|
|
108
|
-
var defaultImageItemClass =
|
|
109
|
-
var defaultPaginationContainerClass =
|
|
106
|
+
var defaultContainerClass = "h-full flex flex-col justify-between";
|
|
107
|
+
var defaultGridClass = "grid grid-cols-[repeat(auto-fill,minmax(calc(160px),1fr))] gap-5";
|
|
108
|
+
var defaultImageItemClass = "cursor-pointer w-full h-40 object-contain p-3 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
110
|
return /*#__PURE__*/_jsxs("div", {
|
|
111
111
|
className: className || defaultContainerClass,
|
|
112
112
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
@@ -118,7 +118,7 @@ var ImagesGallery = function ImagesGallery(_ref) {
|
|
|
118
118
|
apiService: apiService,
|
|
119
119
|
onUploadError: onError
|
|
120
120
|
}), isLoading ? /*#__PURE__*/_jsx(ImagesSkeleton, {}) : images === null || images === void 0 ? void 0 : images.map(function (image, index) {
|
|
121
|
-
var imageUrl = typeof image ===
|
|
121
|
+
var imageUrl = typeof image === "string" ? image : image.url;
|
|
122
122
|
var imageKey = image.id || image.url || index;
|
|
123
123
|
return /*#__PURE__*/_jsx("img", {
|
|
124
124
|
onClick: function onClick() {
|
|
@@ -126,7 +126,7 @@ var ImagesGallery = function ImagesGallery(_ref) {
|
|
|
126
126
|
},
|
|
127
127
|
className: imageItemClassName || defaultImageItemClass,
|
|
128
128
|
src: imageUrl,
|
|
129
|
-
alt: image.name ||
|
|
129
|
+
alt: image.name || "Media item"
|
|
130
130
|
}, imageKey);
|
|
131
131
|
})]
|
|
132
132
|
}), /*#__PURE__*/_jsx("div", {
|
|
@@ -4,15 +4,15 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
4
4
|
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; }
|
|
5
5
|
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; } }
|
|
6
6
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
7
|
-
import React, { useMemo, useState } from
|
|
8
|
-
import ImagesGallery from
|
|
9
|
-
import VideosGallery from
|
|
7
|
+
import React, { useMemo, useState } from "react";
|
|
8
|
+
import ImagesGallery from "./MediaGallery.web";
|
|
9
|
+
import VideosGallery from "./VideosGallery.web";
|
|
10
10
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
11
11
|
function classNames() {
|
|
12
12
|
for (var _len = arguments.length, classes = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
13
13
|
classes[_key] = arguments[_key];
|
|
14
14
|
}
|
|
15
|
-
return classes.filter(Boolean).join(
|
|
15
|
+
return classes.filter(Boolean).join(" ");
|
|
16
16
|
}
|
|
17
17
|
var MediaTab = function MediaTab(_ref) {
|
|
18
18
|
var imagePopup = _ref.imagePopup,
|
|
@@ -35,9 +35,9 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
35
35
|
// Build a stable list of enabled tabs in order
|
|
36
36
|
var availableTabs = useMemo(function () {
|
|
37
37
|
var tabs = [];
|
|
38
|
-
if (options !== null && options !== void 0 && options.includes(
|
|
39
|
-
if (options !== null && options !== void 0 && options.includes(
|
|
40
|
-
if (options !== null && options !== void 0 && options.includes(
|
|
38
|
+
if (options !== null && options !== void 0 && options.includes("image")) tabs.push("image");
|
|
39
|
+
if (options !== null && options !== void 0 && options.includes("video")) tabs.push("video");
|
|
40
|
+
if (options !== null && options !== void 0 && options.includes("file")) tabs.push("file");
|
|
41
41
|
return tabs;
|
|
42
42
|
}, [options]);
|
|
43
43
|
var _useState = useState(0),
|
|
@@ -51,24 +51,24 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
// Default classes with customization support
|
|
54
|
-
var defaultTabGroupClass =
|
|
55
|
-
var defaultTabListClass =
|
|
56
|
-
var defaultTabButtonBaseClass =
|
|
54
|
+
var defaultTabGroupClass = "h-[520px] overflow-y-auto scrollbar-none";
|
|
55
|
+
var defaultTabListClass = "sticky top-0 z-30 bg-white w-full flex border-b-2 border-gray-200";
|
|
56
|
+
var defaultTabButtonBaseClass = "rounded-lg py-2.5 px-8 text-base font-medium leading-5 flex flex-col md:flex-row items-center justify-center gap-3 ring-0 focus:outline-none";
|
|
57
57
|
var defaultTabButtonActiveClass = 'relative text-primary after:content-[""] after:h-1 after:w-full after:block after:absolute after:-bottom-0.5 after:bg-primary after:rounded-card';
|
|
58
|
-
var defaultTabButtonInactiveClass =
|
|
59
|
-
var defaultTabPanelClass =
|
|
58
|
+
var defaultTabButtonInactiveClass = "text-[#4F4F4F]";
|
|
59
|
+
var defaultTabPanelClass = "h-full py-4 relative";
|
|
60
60
|
var handleKeyDown = function handleKeyDown(event, index) {
|
|
61
|
-
if (event.key ===
|
|
61
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
62
62
|
event.preventDefault();
|
|
63
63
|
setSelectedIndex(index);
|
|
64
64
|
}
|
|
65
|
-
if (event.key ===
|
|
65
|
+
if (event.key === "ArrowRight") {
|
|
66
66
|
event.preventDefault();
|
|
67
67
|
setSelectedIndex(function (prev) {
|
|
68
68
|
return (prev + 1) % availableTabs.length;
|
|
69
69
|
});
|
|
70
70
|
}
|
|
71
|
-
if (event.key ===
|
|
71
|
+
if (event.key === "ArrowLeft") {
|
|
72
72
|
event.preventDefault();
|
|
73
73
|
setSelectedIndex(function (prev) {
|
|
74
74
|
return (prev - 1 + availableTabs.length) % availableTabs.length;
|
|
@@ -76,13 +76,13 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
76
76
|
}
|
|
77
77
|
};
|
|
78
78
|
var renderTabLabel = function renderTabLabel(type) {
|
|
79
|
-
if (type ===
|
|
80
|
-
if (type ===
|
|
81
|
-
if (type ===
|
|
79
|
+
if (type === "image") return "Images";
|
|
80
|
+
if (type === "video") return "Videos";
|
|
81
|
+
if (type === "file") return "Files";
|
|
82
82
|
return type;
|
|
83
83
|
};
|
|
84
84
|
var renderPanel = function renderPanel(type) {
|
|
85
|
-
if (type ===
|
|
85
|
+
if (type === "image") {
|
|
86
86
|
return /*#__PURE__*/_jsx(ImagesGallery, {
|
|
87
87
|
imagePopup: imagePopup,
|
|
88
88
|
update_data: update_data,
|
|
@@ -95,7 +95,7 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
95
95
|
paginationContainerClassName: paginationContainerClassName
|
|
96
96
|
});
|
|
97
97
|
}
|
|
98
|
-
if (type ===
|
|
98
|
+
if (type === "video") {
|
|
99
99
|
return /*#__PURE__*/_jsx(VideosGallery, {
|
|
100
100
|
imagePopup: imagePopup,
|
|
101
101
|
update_data: update_data,
|
|
@@ -108,9 +108,9 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
108
108
|
paginationContainerClassName: paginationContainerClassName
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
|
-
if (type ===
|
|
112
|
-
//
|
|
113
|
-
return /*#__PURE__*/_jsx(
|
|
111
|
+
if (type === "file") {
|
|
112
|
+
// Use FilesGallery for non-image, non-video files
|
|
113
|
+
return /*#__PURE__*/_jsx(FilesGallery, {
|
|
114
114
|
imagePopup: imagePopup,
|
|
115
115
|
update_data: update_data,
|
|
116
116
|
current_data: current_data,
|
|
@@ -118,7 +118,7 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
118
118
|
apiService: apiService,
|
|
119
119
|
onError: onError,
|
|
120
120
|
gridClassName: gridClassName,
|
|
121
|
-
|
|
121
|
+
fileItemClassName: imageItemClassName,
|
|
122
122
|
paginationContainerClassName: paginationContainerClassName
|
|
123
123
|
});
|
|
124
124
|
}
|
|
@@ -136,7 +136,7 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
136
136
|
var activeClass = tabButtonActiveClassName || defaultTabButtonActiveClass;
|
|
137
137
|
var inactiveClass = tabButtonInactiveClassName || defaultTabButtonInactiveClass;
|
|
138
138
|
var tabClassName = classNames(baseClass, isSelected ? activeClass : inactiveClass);
|
|
139
|
-
var id = type ===
|
|
139
|
+
var id = type === "image" ? "image-tab-button" : type === "video" ? "video-tab-button" : "file-tab-button";
|
|
140
140
|
return /*#__PURE__*/_jsx("button", {
|
|
141
141
|
id: id,
|
|
142
142
|
type: "button",
|
|
@@ -161,7 +161,7 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
161
161
|
role: "tabpanel",
|
|
162
162
|
children: availableTabs.map(function (type, index) {
|
|
163
163
|
var isSelected = index === selectedIndex;
|
|
164
|
-
var id = type ===
|
|
164
|
+
var id = type === "image" ? "image-tab-button" : type === "video" ? "video-tab-button" : "file-tab-button";
|
|
165
165
|
return /*#__PURE__*/_jsx("div", {
|
|
166
166
|
id: "".concat(id, "-panel"),
|
|
167
167
|
role: "tabpanel",
|
|
@@ -8,12 +8,12 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
8
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
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
10
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
11
|
-
import React, { useState, useEffect } from
|
|
12
|
-
import FileUpload from
|
|
13
|
-
import ImagesSkeleton from
|
|
14
|
-
import Pagination from
|
|
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 { VIDEO_MIME_TYPES } from "../core/FileTypes";
|
|
15
16
|
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
17
|
var VideosGallery = function VideosGallery(_ref) {
|
|
18
18
|
var update_data = _ref.update_data,
|
|
19
19
|
closePopup = _ref.closePopup,
|
|
@@ -80,7 +80,7 @@ var VideosGallery = function VideosGallery(_ref) {
|
|
|
80
80
|
case 3:
|
|
81
81
|
_context.p = 3;
|
|
82
82
|
_t = _context.v;
|
|
83
|
-
console.error(
|
|
83
|
+
console.error("Error loading videos:", _t);
|
|
84
84
|
if (onError) {
|
|
85
85
|
onError(_t);
|
|
86
86
|
}
|
|
@@ -103,10 +103,10 @@ var VideosGallery = function VideosGallery(_ref) {
|
|
|
103
103
|
};
|
|
104
104
|
|
|
105
105
|
// Default classes with customization support
|
|
106
|
-
var defaultContainerClass =
|
|
107
|
-
var defaultGridClass =
|
|
108
|
-
var defaultVideoItemClass =
|
|
109
|
-
var defaultPaginationContainerClass =
|
|
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
110
|
return /*#__PURE__*/_jsxs("div", {
|
|
111
111
|
className: className || defaultContainerClass,
|
|
112
112
|
children: [/*#__PURE__*/_jsxs("div", {
|
|
@@ -118,7 +118,7 @@ var VideosGallery = function VideosGallery(_ref) {
|
|
|
118
118
|
apiService: apiService,
|
|
119
119
|
onUploadError: onError
|
|
120
120
|
}), isLoading ? /*#__PURE__*/_jsx(ImagesSkeleton, {}) : videos === null || videos === void 0 ? void 0 : videos.map(function (video, index) {
|
|
121
|
-
var videoUrl = typeof video ===
|
|
121
|
+
var videoUrl = typeof video === "string" ? video : video.url;
|
|
122
122
|
var videoKey = video.id || video.url || index;
|
|
123
123
|
return /*#__PURE__*/_jsx("video", {
|
|
124
124
|
onClick: function onClick() {
|