PreviewGroup.js
2.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
import * as React from 'react';
import Preview from './Preview';
export var context = /*#__PURE__*/React.createContext({
previewUrls: [],
setPreviewUrls: function setPreviewUrls() {
return null;
},
setCurrent: function setCurrent() {
return null;
},
setShowPreview: function setShowPreview() {
return null;
},
setMousePosition: function setMousePosition() {
return null;
}
});
var Provider = context.Provider;
var Group = function Group(_ref) {
var _ref$previewPrefixCls = _ref.previewPrefixCls,
previewPrefixCls = _ref$previewPrefixCls === void 0 ? 'rc-image-preview' : _ref$previewPrefixCls,
children = _ref.children;
var _React$useState = React.useState([]),
_React$useState2 = _slicedToArray(_React$useState, 2),
previewUrls = _React$useState2[0],
setPreviewUrls = _React$useState2[1];
var _React$useState3 = React.useState(),
_React$useState4 = _slicedToArray(_React$useState3, 2),
current = _React$useState4[0],
setCurrent = _React$useState4[1];
var _React$useState5 = React.useState(false),
_React$useState6 = _slicedToArray(_React$useState5, 2),
isShowPreview = _React$useState6[0],
setShowPreview = _React$useState6[1];
var _React$useState7 = React.useState(null),
_React$useState8 = _slicedToArray(_React$useState7, 2),
mousePosition = _React$useState8[0],
setMousePosition = _React$useState8[1];
var onPreviewClose = function onPreviewClose(e) {
e.stopPropagation();
setShowPreview(false);
setMousePosition(null);
};
return /*#__PURE__*/React.createElement(Provider, {
value: {
isPreviewGroup: true,
previewUrls: previewUrls,
setPreviewUrls: setPreviewUrls,
setCurrent: setCurrent,
setShowPreview: setShowPreview,
setMousePosition: setMousePosition
}
}, children, /*#__PURE__*/React.createElement(Preview, {
"ria-hidden": !isShowPreview,
visible: isShowPreview,
prefixCls: previewPrefixCls,
onClose: onPreviewClose,
mousePosition: mousePosition,
src: current
}));
};
export default Group;