PreviewGroup.js
2.63 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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
"use strict";
var _interopRequireWildcard = require("@babel/runtime/helpers/interopRequireWildcard");
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = exports.context = void 0;
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
var React = _interopRequireWildcard(require("react"));
var _Preview = _interopRequireDefault(require("./Preview"));
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;
}
});
exports.context = context;
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 = (0, _slicedToArray2.default)(_React$useState, 2),
previewUrls = _React$useState2[0],
setPreviewUrls = _React$useState2[1];
var _React$useState3 = React.useState(),
_React$useState4 = (0, _slicedToArray2.default)(_React$useState3, 2),
current = _React$useState4[0],
setCurrent = _React$useState4[1];
var _React$useState5 = React.useState(false),
_React$useState6 = (0, _slicedToArray2.default)(_React$useState5, 2),
isShowPreview = _React$useState6[0],
setShowPreview = _React$useState6[1];
var _React$useState7 = React.useState(null),
_React$useState8 = (0, _slicedToArray2.default)(_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.default, {
"ria-hidden": !isShowPreview,
visible: isShowPreview,
prefixCls: previewPrefixCls,
onClose: onPreviewClose,
mousePosition: mousePosition,
src: current
}));
};
var _default = Group;
exports.default = _default;