@sutech_jp/raas-react-client 0.1.28 → 0.1.29
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/webform/ReportWebForm.js +39 -20
- package/package.json +1 -1
|
@@ -7,8 +7,18 @@ var targetOrigin_1 = require("../util/targetOrigin");
|
|
|
7
7
|
var ReportWebForm = function (_a) {
|
|
8
8
|
var session = _a.session, _b = _a.width, width = _b === void 0 ? '100%' : _b, _c = _a.height, height = _c === void 0 ? '100%' : _c, customStyles = _a.customStyles, title = _a.title, layoutId = _a.layoutId, values = _a.values, fileName = _a.fileName, options = _a.options, validateCustom = _a.validateCustom, onChange = _a.onChange, onGenerate = _a.onGenerate;
|
|
9
9
|
var iframe = (0, react_1.useRef)(null);
|
|
10
|
-
var
|
|
10
|
+
var sendMessage = (0, react_1.useCallback)(function (action, props) {
|
|
11
11
|
var _a;
|
|
12
|
+
var iframeWindow = (_a = iframe.current) === null || _a === void 0 ? void 0 : _a.contentWindow;
|
|
13
|
+
if (!iframeWindow)
|
|
14
|
+
return;
|
|
15
|
+
iframeWindow.postMessage({
|
|
16
|
+
from: 'webformClient',
|
|
17
|
+
action: action,
|
|
18
|
+
props: props,
|
|
19
|
+
}, (0, targetOrigin_1.getTargetOrigin)(session === null || session === void 0 ? void 0 : session.newUrl));
|
|
20
|
+
}, [session === null || session === void 0 ? void 0 : session.newUrl]);
|
|
21
|
+
var handleMessage = (0, react_1.useCallback)(function (e) {
|
|
12
22
|
if ((0, targetOrigin_1.getTargetOrigin)(session === null || session === void 0 ? void 0 : session.newUrl) !== '*' && e.origin !== (0, targetOrigin_1.getTargetOrigin)(session === null || session === void 0 ? void 0 : session.newUrl)) {
|
|
13
23
|
return;
|
|
14
24
|
}
|
|
@@ -19,35 +29,44 @@ var ReportWebForm = function (_a) {
|
|
|
19
29
|
return;
|
|
20
30
|
}
|
|
21
31
|
if (action === 'onAuthorized') {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
title: title,
|
|
31
|
-
layoutId: layoutId,
|
|
32
|
-
values: values,
|
|
33
|
-
fileName: fileName,
|
|
34
|
-
options: options,
|
|
35
|
-
},
|
|
36
|
-
}, (0, targetOrigin_1.getTargetOrigin)(session === null || session === void 0 ? void 0 : session.newUrl));
|
|
32
|
+
sendMessage('onShow', {
|
|
33
|
+
customStyles: customStyles,
|
|
34
|
+
title: title,
|
|
35
|
+
layoutId: layoutId,
|
|
36
|
+
values: values,
|
|
37
|
+
fileName: fileName,
|
|
38
|
+
options: options,
|
|
39
|
+
});
|
|
37
40
|
}
|
|
38
41
|
else if (action === 'validateCustom') {
|
|
39
|
-
|
|
40
|
-
|
|
42
|
+
if (!validateCustom) {
|
|
43
|
+
return;
|
|
44
|
+
}
|
|
45
|
+
var _a = message.payload, property = _a.property, rowIndex = _a.rowIndex, value = _a.value, values_1 = _a.values;
|
|
46
|
+
var result = validateCustom(property, rowIndex, value, values_1);
|
|
47
|
+
sendMessage('onValidated', result);
|
|
41
48
|
}
|
|
42
49
|
else if (action === 'onChange') {
|
|
43
|
-
var
|
|
50
|
+
var _b = message.payload, property = _b.property, rowIndex = _b.rowIndex, value = _b.value, values_2 = _b.values;
|
|
44
51
|
onChange === null || onChange === void 0 ? void 0 : onChange(property, rowIndex, value, values_2);
|
|
45
52
|
}
|
|
46
53
|
else if (action === 'onGenerate') {
|
|
47
54
|
var logId = message.payload;
|
|
48
55
|
onGenerate === null || onGenerate === void 0 ? void 0 : onGenerate(logId);
|
|
49
56
|
}
|
|
50
|
-
}, [
|
|
57
|
+
}, [
|
|
58
|
+
customStyles,
|
|
59
|
+
fileName,
|
|
60
|
+
layoutId,
|
|
61
|
+
onChange,
|
|
62
|
+
onGenerate,
|
|
63
|
+
options,
|
|
64
|
+
sendMessage,
|
|
65
|
+
session === null || session === void 0 ? void 0 : session.newUrl,
|
|
66
|
+
title,
|
|
67
|
+
validateCustom,
|
|
68
|
+
values,
|
|
69
|
+
]);
|
|
51
70
|
(0, react_1.useEffect)(function () {
|
|
52
71
|
window.addEventListener('message', handleMessage);
|
|
53
72
|
return function () { return window.removeEventListener('message', handleMessage); };
|