UNPKG

1.07 kBJavaScriptView Raw
1import React from 'react';
2import { ImageViewer, MultiImageViewer } from './image-viewer';
3import { renderImperatively } from '../../utils/render-imperatively';
4const handlerSet = new Set();
5export function showImageViewer(props) {
6 clearImageViewer();
7 const handler = renderImperatively(React.createElement(ImageViewer, Object.assign({}, props, {
8 afterClose: () => {
9 var _a;
10 handlerSet.delete(handler);
11 (_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
12 }
13 })));
14 handlerSet.add(handler);
15 return handler;
16}
17export function showMultiImageViewer(props) {
18 clearImageViewer();
19 const handler = renderImperatively(React.createElement(MultiImageViewer, Object.assign({}, props, {
20 afterClose: () => {
21 var _a;
22 handlerSet.delete(handler);
23 (_a = props.afterClose) === null || _a === void 0 ? void 0 : _a.call(props);
24 }
25 })));
26 handlerSet.add(handler);
27 return handler;
28}
29export function clearImageViewer() {
30 handlerSet.forEach(handler => {
31 handler.close();
32 });
33 handlerSet.clear();
34}
\No newline at end of file