@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
|
@@ -9,6 +9,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
var _FileUpload = _interopRequireDefault(require("./FileUpload.web"));
|
|
10
10
|
var _ImagesSkeleton = _interopRequireDefault(require("./ImagesSkeleton.web"));
|
|
11
11
|
var _Pagination = _interopRequireDefault(require("./Pagination.web"));
|
|
12
|
+
var _FileTypes = require("../core/FileTypes");
|
|
12
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
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 _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); }
|
|
@@ -22,7 +23,6 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
22
23
|
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; }
|
|
23
24
|
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; } }
|
|
24
25
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
25
|
-
var IMAGE_MIME_TYPES = ['image/png', 'image/jpeg', 'image/webp', 'image/svg+xml', 'image/gif', 'image/avif', 'image/x-icon', 'image/vnd.microsoft.icon', 'image/heic', 'image/heif'];
|
|
26
26
|
var ImagesGallery = function ImagesGallery(_ref) {
|
|
27
27
|
var update_data = _ref.update_data,
|
|
28
28
|
closePopup = _ref.closePopup,
|
|
@@ -70,7 +70,7 @@ var ImagesGallery = function ImagesGallery(_ref) {
|
|
|
70
70
|
_context.p = 1;
|
|
71
71
|
_context.n = 2;
|
|
72
72
|
return apiService.fetchMedia({
|
|
73
|
-
mimeTypes: IMAGE_MIME_TYPES,
|
|
73
|
+
mimeTypes: _FileTypes.IMAGE_MIME_TYPES,
|
|
74
74
|
page: page_number,
|
|
75
75
|
setISLoading: setISLoading,
|
|
76
76
|
isLoading: isLoading
|
|
@@ -89,7 +89,7 @@ var ImagesGallery = function ImagesGallery(_ref) {
|
|
|
89
89
|
case 3:
|
|
90
90
|
_context.p = 3;
|
|
91
91
|
_t = _context.v;
|
|
92
|
-
console.error(
|
|
92
|
+
console.error("Error loading media:", _t);
|
|
93
93
|
if (onError) {
|
|
94
94
|
onError(_t);
|
|
95
95
|
}
|
|
@@ -112,10 +112,10 @@ var ImagesGallery = function ImagesGallery(_ref) {
|
|
|
112
112
|
};
|
|
113
113
|
|
|
114
114
|
// Default classes with customization support
|
|
115
|
-
var defaultContainerClass =
|
|
116
|
-
var defaultGridClass =
|
|
117
|
-
var defaultImageItemClass =
|
|
118
|
-
var defaultPaginationContainerClass =
|
|
115
|
+
var defaultContainerClass = "h-full flex flex-col justify-between";
|
|
116
|
+
var defaultGridClass = "grid grid-cols-[repeat(auto-fill,minmax(calc(160px),1fr))] gap-5";
|
|
117
|
+
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";
|
|
118
|
+
var defaultPaginationContainerClass = "mb-4 bg-gray-100/90 p-4 sticky bottom-0";
|
|
119
119
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
120
120
|
className: className || defaultContainerClass,
|
|
121
121
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
@@ -127,7 +127,7 @@ var ImagesGallery = function ImagesGallery(_ref) {
|
|
|
127
127
|
apiService: apiService,
|
|
128
128
|
onUploadError: onError
|
|
129
129
|
}), isLoading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ImagesSkeleton.default, {}) : images === null || images === void 0 ? void 0 : images.map(function (image, index) {
|
|
130
|
-
var imageUrl = typeof image ===
|
|
130
|
+
var imageUrl = typeof image === "string" ? image : image.url;
|
|
131
131
|
var imageKey = image.id || image.url || index;
|
|
132
132
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("img", {
|
|
133
133
|
onClick: function onClick() {
|
|
@@ -135,7 +135,7 @@ var ImagesGallery = function ImagesGallery(_ref) {
|
|
|
135
135
|
},
|
|
136
136
|
className: imageItemClassName || defaultImageItemClass,
|
|
137
137
|
src: imageUrl,
|
|
138
|
-
alt: image.name ||
|
|
138
|
+
alt: image.name || "Media item"
|
|
139
139
|
}, imageKey);
|
|
140
140
|
})]
|
|
141
141
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
package/dist/web/MediaTab.web.js
CHANGED
|
@@ -21,7 +21,7 @@ function classNames() {
|
|
|
21
21
|
for (var _len = arguments.length, classes = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
22
22
|
classes[_key] = arguments[_key];
|
|
23
23
|
}
|
|
24
|
-
return classes.filter(Boolean).join(
|
|
24
|
+
return classes.filter(Boolean).join(" ");
|
|
25
25
|
}
|
|
26
26
|
var MediaTab = function MediaTab(_ref) {
|
|
27
27
|
var imagePopup = _ref.imagePopup,
|
|
@@ -44,9 +44,9 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
44
44
|
// Build a stable list of enabled tabs in order
|
|
45
45
|
var availableTabs = (0, _react.useMemo)(function () {
|
|
46
46
|
var tabs = [];
|
|
47
|
-
if (options !== null && options !== void 0 && options.includes(
|
|
48
|
-
if (options !== null && options !== void 0 && options.includes(
|
|
49
|
-
if (options !== null && options !== void 0 && options.includes(
|
|
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
50
|
return tabs;
|
|
51
51
|
}, [options]);
|
|
52
52
|
var _useState = (0, _react.useState)(0),
|
|
@@ -60,24 +60,24 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
60
60
|
}
|
|
61
61
|
|
|
62
62
|
// Default classes with customization support
|
|
63
|
-
var defaultTabGroupClass =
|
|
64
|
-
var defaultTabListClass =
|
|
65
|
-
var defaultTabButtonBaseClass =
|
|
63
|
+
var defaultTabGroupClass = "h-[520px] overflow-y-auto scrollbar-none";
|
|
64
|
+
var defaultTabListClass = "sticky top-0 z-30 bg-white w-full flex border-b-2 border-gray-200";
|
|
65
|
+
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";
|
|
66
66
|
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';
|
|
67
|
-
var defaultTabButtonInactiveClass =
|
|
68
|
-
var defaultTabPanelClass =
|
|
67
|
+
var defaultTabButtonInactiveClass = "text-[#4F4F4F]";
|
|
68
|
+
var defaultTabPanelClass = "h-full py-4 relative";
|
|
69
69
|
var handleKeyDown = function handleKeyDown(event, index) {
|
|
70
|
-
if (event.key ===
|
|
70
|
+
if (event.key === "Enter" || event.key === " ") {
|
|
71
71
|
event.preventDefault();
|
|
72
72
|
setSelectedIndex(index);
|
|
73
73
|
}
|
|
74
|
-
if (event.key ===
|
|
74
|
+
if (event.key === "ArrowRight") {
|
|
75
75
|
event.preventDefault();
|
|
76
76
|
setSelectedIndex(function (prev) {
|
|
77
77
|
return (prev + 1) % availableTabs.length;
|
|
78
78
|
});
|
|
79
79
|
}
|
|
80
|
-
if (event.key ===
|
|
80
|
+
if (event.key === "ArrowLeft") {
|
|
81
81
|
event.preventDefault();
|
|
82
82
|
setSelectedIndex(function (prev) {
|
|
83
83
|
return (prev - 1 + availableTabs.length) % availableTabs.length;
|
|
@@ -85,13 +85,13 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
85
85
|
}
|
|
86
86
|
};
|
|
87
87
|
var renderTabLabel = function renderTabLabel(type) {
|
|
88
|
-
if (type ===
|
|
89
|
-
if (type ===
|
|
90
|
-
if (type ===
|
|
88
|
+
if (type === "image") return "Images";
|
|
89
|
+
if (type === "video") return "Videos";
|
|
90
|
+
if (type === "file") return "Files";
|
|
91
91
|
return type;
|
|
92
92
|
};
|
|
93
93
|
var renderPanel = function renderPanel(type) {
|
|
94
|
-
if (type ===
|
|
94
|
+
if (type === "image") {
|
|
95
95
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_MediaGallery.default, {
|
|
96
96
|
imagePopup: imagePopup,
|
|
97
97
|
update_data: update_data,
|
|
@@ -104,7 +104,7 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
104
104
|
paginationContainerClassName: paginationContainerClassName
|
|
105
105
|
});
|
|
106
106
|
}
|
|
107
|
-
if (type ===
|
|
107
|
+
if (type === "video") {
|
|
108
108
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_VideosGallery.default, {
|
|
109
109
|
imagePopup: imagePopup,
|
|
110
110
|
update_data: update_data,
|
|
@@ -117,9 +117,9 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
117
117
|
paginationContainerClassName: paginationContainerClassName
|
|
118
118
|
});
|
|
119
119
|
}
|
|
120
|
-
if (type ===
|
|
121
|
-
//
|
|
122
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
120
|
+
if (type === "file") {
|
|
121
|
+
// Use FilesGallery for non-image, non-video files
|
|
122
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(FilesGallery, {
|
|
123
123
|
imagePopup: imagePopup,
|
|
124
124
|
update_data: update_data,
|
|
125
125
|
current_data: current_data,
|
|
@@ -127,7 +127,7 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
127
127
|
apiService: apiService,
|
|
128
128
|
onError: onError,
|
|
129
129
|
gridClassName: gridClassName,
|
|
130
|
-
|
|
130
|
+
fileItemClassName: imageItemClassName,
|
|
131
131
|
paginationContainerClassName: paginationContainerClassName
|
|
132
132
|
});
|
|
133
133
|
}
|
|
@@ -145,7 +145,7 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
145
145
|
var activeClass = tabButtonActiveClassName || defaultTabButtonActiveClass;
|
|
146
146
|
var inactiveClass = tabButtonInactiveClassName || defaultTabButtonInactiveClass;
|
|
147
147
|
var tabClassName = classNames(baseClass, isSelected ? activeClass : inactiveClass);
|
|
148
|
-
var id = type ===
|
|
148
|
+
var id = type === "image" ? "image-tab-button" : type === "video" ? "video-tab-button" : "file-tab-button";
|
|
149
149
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
150
150
|
id: id,
|
|
151
151
|
type: "button",
|
|
@@ -170,7 +170,7 @@ var MediaTab = function MediaTab(_ref) {
|
|
|
170
170
|
role: "tabpanel",
|
|
171
171
|
children: availableTabs.map(function (type, index) {
|
|
172
172
|
var isSelected = index === selectedIndex;
|
|
173
|
-
var id = type ===
|
|
173
|
+
var id = type === "image" ? "image-tab-button" : type === "video" ? "video-tab-button" : "file-tab-button";
|
|
174
174
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
175
175
|
id: "".concat(id, "-panel"),
|
|
176
176
|
role: "tabpanel",
|
|
@@ -9,6 +9,7 @@ var _react = _interopRequireWildcard(require("react"));
|
|
|
9
9
|
var _FileUpload = _interopRequireDefault(require("./FileUpload.web"));
|
|
10
10
|
var _ImagesSkeleton = _interopRequireDefault(require("./ImagesSkeleton.web"));
|
|
11
11
|
var _Pagination = _interopRequireDefault(require("./Pagination.web"));
|
|
12
|
+
var _FileTypes = require("../core/FileTypes");
|
|
12
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
14
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
14
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 _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); }
|
|
@@ -22,7 +23,6 @@ function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r)
|
|
|
22
23
|
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; }
|
|
23
24
|
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; } }
|
|
24
25
|
function _arrayWithHoles(r) { if (Array.isArray(r)) return r; }
|
|
25
|
-
var VIDEO_MIME_TYPES = ['video/mp4', 'video/quicktime', 'video/x-ms-wmv', 'video/h265', 'video/hevc', 'video/webm'];
|
|
26
26
|
var VideosGallery = function VideosGallery(_ref) {
|
|
27
27
|
var update_data = _ref.update_data,
|
|
28
28
|
closePopup = _ref.closePopup,
|
|
@@ -70,7 +70,7 @@ var VideosGallery = function VideosGallery(_ref) {
|
|
|
70
70
|
_context.p = 1;
|
|
71
71
|
_context.n = 2;
|
|
72
72
|
return apiService.fetchMedia({
|
|
73
|
-
mimeTypes: VIDEO_MIME_TYPES,
|
|
73
|
+
mimeTypes: _FileTypes.VIDEO_MIME_TYPES,
|
|
74
74
|
page: page_number,
|
|
75
75
|
setISLoading: setISLoading,
|
|
76
76
|
isLoading: isLoading
|
|
@@ -89,7 +89,7 @@ var VideosGallery = function VideosGallery(_ref) {
|
|
|
89
89
|
case 3:
|
|
90
90
|
_context.p = 3;
|
|
91
91
|
_t = _context.v;
|
|
92
|
-
console.error(
|
|
92
|
+
console.error("Error loading videos:", _t);
|
|
93
93
|
if (onError) {
|
|
94
94
|
onError(_t);
|
|
95
95
|
}
|
|
@@ -112,10 +112,10 @@ var VideosGallery = function VideosGallery(_ref) {
|
|
|
112
112
|
};
|
|
113
113
|
|
|
114
114
|
// Default classes with customization support
|
|
115
|
-
var defaultContainerClass =
|
|
116
|
-
var defaultGridClass =
|
|
117
|
-
var defaultVideoItemClass =
|
|
118
|
-
var defaultPaginationContainerClass =
|
|
115
|
+
var defaultContainerClass = "h-full flex flex-col justify-between";
|
|
116
|
+
var defaultGridClass = "grid grid-cols-[repeat(auto-fill,minmax(calc(180px),1fr))] gap-5";
|
|
117
|
+
var defaultVideoItemClass = "cursor-pointer w-full h-40 object-contain overflow-hidden bg-white rounded-md shadow-md hover:shadow-lg transition-shadow";
|
|
118
|
+
var defaultPaginationContainerClass = "mb-4 bg-gray-100/90 p-4 sticky bottom-0";
|
|
119
119
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
120
120
|
className: className || defaultContainerClass,
|
|
121
121
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
@@ -127,7 +127,7 @@ var VideosGallery = function VideosGallery(_ref) {
|
|
|
127
127
|
apiService: apiService,
|
|
128
128
|
onUploadError: onError
|
|
129
129
|
}), isLoading ? /*#__PURE__*/(0, _jsxRuntime.jsx)(_ImagesSkeleton.default, {}) : videos === null || videos === void 0 ? void 0 : videos.map(function (video, index) {
|
|
130
|
-
var videoUrl = typeof video ===
|
|
130
|
+
var videoUrl = typeof video === "string" ? video : video.url;
|
|
131
131
|
var videoKey = video.id || video.url || index;
|
|
132
132
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("video", {
|
|
133
133
|
onClick: function onClick() {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tradly/asset",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.23",
|
|
4
4
|
"description": "A reusable media gallery component for uploading and selecting images, videos, and files with Tradly authentication",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|