indicator-ui 0.0.178 → 0.0.180
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/index.js
CHANGED
|
@@ -11886,8 +11886,8 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
11886
11886
|
|
|
11887
11887
|
|
|
11888
11888
|
|
|
11889
|
-
function MediaViewer({ media = [], initMediaIndex, onClose }) {
|
|
11890
|
-
const [curMediaIndex, setCurMediaIndex] = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(initMediaIndex && initMediaIndex >= 0 && media.length
|
|
11889
|
+
function MediaViewer({ media = [], initMediaIndex, nearestElementsOnly = true, onClose }) {
|
|
11890
|
+
const [curMediaIndex, setCurMediaIndex] = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(initMediaIndex != null && initMediaIndex >= 0 && initMediaIndex < media.length ? initMediaIndex : 0);
|
|
11891
11891
|
const [muted, setMuted] = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(false);
|
|
11892
11892
|
const [play, setPlay] = (0,react__WEBPACK_IMPORTED_MODULE_1__.useState)(false);
|
|
11893
11893
|
const resetVideo = () => {
|
|
@@ -11908,14 +11908,19 @@ function MediaViewer({ media = [], initMediaIndex, onClose }) {
|
|
|
11908
11908
|
const _play = () => {
|
|
11909
11909
|
setPlay(prevState => !prevState);
|
|
11910
11910
|
};
|
|
11911
|
+
const isNearestElement = (curEl, el) => {
|
|
11912
|
+
const nextEl = curEl + 1 < media.length ? curEl + 1 : media.length - 1;
|
|
11913
|
+
const prevEl = curEl - 1 >= 0 ? curEl - 1 : 0;
|
|
11914
|
+
return nextEl === el || prevEl === el || el === curEl;
|
|
11915
|
+
};
|
|
11911
11916
|
const getContent = (item, idx) => {
|
|
11912
|
-
if (item == null ||
|
|
11917
|
+
if (item == null || (nearestElementsOnly && !isNearestElement(curMediaIndex, idx)))
|
|
11913
11918
|
return undefined;
|
|
11914
11919
|
switch (item.type) {
|
|
11915
11920
|
case 'video':
|
|
11916
|
-
return (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_components__WEBPACK_IMPORTED_MODULE_2__.VideoViewer, { src: item.src, muted: curMediaIndex === idx ? muted : undefined, play: curMediaIndex === idx ? play : undefined, onChangePlay: curMediaIndex === idx ? (play) => setPlay(play) : undefined },
|
|
11921
|
+
return (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_components__WEBPACK_IMPORTED_MODULE_2__.VideoViewer, { src: item.src, muted: curMediaIndex === idx ? muted : undefined, play: curMediaIndex === idx ? play : undefined, onChangePlay: curMediaIndex === idx ? (play) => setPlay(play) : undefined }, idx);
|
|
11917
11922
|
case 'image':
|
|
11918
|
-
return (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_components__WEBPACK_IMPORTED_MODULE_2__.ImageViewer, { src: item.src },
|
|
11923
|
+
return (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_components__WEBPACK_IMPORTED_MODULE_2__.ImageViewer, { src: item.src }, idx);
|
|
11919
11924
|
default:
|
|
11920
11925
|
return undefined;
|
|
11921
11926
|
}
|
|
@@ -13842,7 +13847,7 @@ __webpack_require__.r(__webpack_exports__);
|
|
|
13842
13847
|
function UserPick({ size = '20', url, additionStyles }) {
|
|
13843
13848
|
const style = { width: `${size}px`, height: `${size}px` };
|
|
13844
13849
|
if (!url) {
|
|
13845
|
-
return (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", { className: (0,clsx__WEBPACK_IMPORTED_MODULE_1__["default"])(_styles__WEBPACK_IMPORTED_MODULE_2__.UserPickStyle.userPickPlaceholder, additionStyles), style: style, children: (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_assets__WEBPACK_IMPORTED_MODULE_3__.PlaceholderSVG, {}) });
|
|
13850
|
+
return ((0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("div", { className: (0,clsx__WEBPACK_IMPORTED_MODULE_1__["default"])(_styles__WEBPACK_IMPORTED_MODULE_2__.UserPickStyle.userPickPlaceholder, additionStyles), style: style, children: (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)(_assets__WEBPACK_IMPORTED_MODULE_3__.PlaceholderSVG, {}) }));
|
|
13846
13851
|
}
|
|
13847
13852
|
return (0,react_jsx_runtime__WEBPACK_IMPORTED_MODULE_0__.jsx)("img", { src: url, alt: '', className: (0,clsx__WEBPACK_IMPORTED_MODULE_1__["default"])(_styles__WEBPACK_IMPORTED_MODULE_2__.UserPickStyle.userPick, additionStyles), style: style });
|
|
13848
13853
|
}
|