@sutech_jp/raas-react-client 0.0.23 → 0.0.25

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.
@@ -6,20 +6,32 @@ var react_1 = require("react");
6
6
  var ReportConfig = function (_a) {
7
7
  var url = _a.url, _b = _a.width, width = _b === void 0 ? '100%' : _b, _c = _a.height, height = _c === void 0 ? '100%' : _c, _d = _a.hideTenantInfoConfig, hideTenantInfoConfig = _d === void 0 ? false : _d, _e = _a.toolbarPosition, toolbarPosition = _e === void 0 ? 'bottom' : _e;
8
8
  var iframe = (0, react_1.useRef)(null);
9
- (0, react_1.useEffect)(function () {
9
+ var handleMessage = (0, react_1.useCallback)(function (e) {
10
10
  var _a;
11
- var iframeWindow = (_a = iframe.current) === null || _a === void 0 ? void 0 : _a.contentWindow;
12
- if (!iframeWindow)
11
+ var message = e.data;
12
+ var from = message === null || message === void 0 ? void 0 : message.from;
13
+ var action = message === null || message === void 0 ? void 0 : message.action;
14
+ if (from !== 'config') {
13
15
  return;
14
- iframeWindow.postMessage({
15
- from: 'configClient',
16
- action: 'onShow',
17
- props: {
18
- hideTenantInfoConfig: hideTenantInfoConfig,
19
- toolbarPosition: toolbarPosition,
20
- },
21
- }, '*');
16
+ }
17
+ if (action === 'onAuthorized') {
18
+ var iframeWindow = (_a = iframe.current) === null || _a === void 0 ? void 0 : _a.contentWindow;
19
+ if (!iframeWindow)
20
+ return;
21
+ iframeWindow.postMessage({
22
+ from: 'configClient',
23
+ action: 'onShow',
24
+ props: {
25
+ hideTenantInfoConfig: hideTenantInfoConfig,
26
+ toolbarPosition: toolbarPosition,
27
+ },
28
+ }, '*');
29
+ }
22
30
  }, [hideTenantInfoConfig, toolbarPosition]);
31
+ (0, react_1.useEffect)(function () {
32
+ window.addEventListener('message', handleMessage);
33
+ return function () { return window.removeEventListener('message', handleMessage); };
34
+ }, [handleMessage]);
23
35
  return (0, jsx_runtime_1.jsx)("iframe", { ref: iframe, id: "config", src: url, style: { width: width, height: height, border: 0 } });
24
36
  };
25
37
  exports.ReportConfig = ReportConfig;
@@ -5,8 +5,9 @@ var jsx_runtime_1 = require("react/jsx-runtime");
5
5
  var react_1 = require("react");
6
6
  var ReportLayoutGallery = function (_a) {
7
7
  var url = _a.url, _b = _a.width, width = _b === void 0 ? '100%' : _b, _c = _a.height, height = _c === void 0 ? '100%' : _c, onSelectLayout = _a.onSelectLayout, onEditLayout = _a.onEditLayout, onCreateLayout = _a.onCreateLayout;
8
+ var iframe = (0, react_1.useRef)(null);
8
9
  var handleMessage = (0, react_1.useCallback)(function (e) {
9
- var _a, _b, _c, _d;
10
+ var _a, _b, _c, _d, _e;
10
11
  var from = (_a = e.data) === null || _a === void 0 ? void 0 : _a.from;
11
12
  var action = (_b = e.data) === null || _b === void 0 ? void 0 : _b.action;
12
13
  if (from !== 'gallery') {
@@ -21,13 +22,25 @@ var ReportLayoutGallery = function (_a) {
21
22
  else if (action === 'createLayout') {
22
23
  onCreateLayout && onCreateLayout();
23
24
  }
25
+ else if (action === 'onAuthorized') {
26
+ var iframeWindow = (_e = iframe.current) === null || _e === void 0 ? void 0 : _e.contentWindow;
27
+ if (!iframeWindow)
28
+ return;
29
+ iframeWindow.postMessage({
30
+ from: 'galleryClient',
31
+ action: 'onShow',
32
+ props: {
33
+ selectable: onSelectLayout !== undefined,
34
+ creatable: onCreateLayout !== undefined,
35
+ editable: onEditLayout !== undefined,
36
+ },
37
+ }, '*');
38
+ }
24
39
  }, [onCreateLayout, onEditLayout, onSelectLayout]);
25
40
  (0, react_1.useEffect)(function () {
26
41
  window.addEventListener('message', handleMessage);
27
42
  return function () { return window.removeEventListener('message', handleMessage); };
28
43
  }, [handleMessage]);
29
- var operation = "".concat(onSelectLayout !== undefined ? 's' : '').concat(onEditLayout !== undefined ? 'e' : '').concat(onCreateLayout !== undefined ? 'c' : '');
30
- var operationalURL = "".concat(url).concat(operation ? "?operation=".concat(operation) : '');
31
- return (0, jsx_runtime_1.jsx)("iframe", { id: "gallery", src: operationalURL, style: { width: width, height: height, border: 0 } });
44
+ return (0, jsx_runtime_1.jsx)("iframe", { ref: iframe, id: "gallery", src: url, style: { width: width, height: height, border: 0 } });
32
45
  };
33
46
  exports.ReportLayoutGallery = ReportLayoutGallery;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sutech_jp/raas-react-client",
3
- "version": "0.0.23",
3
+ "version": "0.0.25",
4
4
  "description": "react client for raas produced by SuTech",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",