@sutech_jp/raas-react-client 0.1.26 → 0.1.28
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/types/index.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { ThemeOptions } from './theme';
|
|
2
2
|
export { ThemeOptions, PaletteOptions, TypographyOptions, ColorOptions, Grayscale, TypographyVariants } from './theme';
|
|
3
|
+
export type { ItemValue, ObjectValue, ArrayValue, BusinessData, ComponentOptions, CustomValidationResult, } from './webform';
|
|
3
4
|
export declare type Layout = any;
|
|
4
5
|
export declare type CustomData = any[];
|
|
5
6
|
export declare type ReportOptions = any[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
export declare type ItemValue = string | number | boolean | Date | null;
|
|
3
|
+
export declare type ObjectValue = {
|
|
4
|
+
[key: string]: ItemValue | ObjectValue | ArrayValue;
|
|
5
|
+
};
|
|
6
|
+
export declare type ArrayValue = ObjectValue[];
|
|
7
|
+
export declare type BusinessData = ObjectValue;
|
|
8
|
+
export declare type ComponentOptions = {
|
|
9
|
+
requiredMark?: ReactNode;
|
|
10
|
+
showReportOutputButton?: boolean;
|
|
11
|
+
};
|
|
12
|
+
export declare type CustomValidationResult = {
|
|
13
|
+
error: boolean;
|
|
14
|
+
message?: string;
|
|
15
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { VFC } from 'react';
|
|
2
|
+
import { BusinessData, CustomValidationResult, ComponentOptions, ItemValue } from 'src/types/webform';
|
|
3
|
+
import { Session } from '../types';
|
|
4
|
+
import { ThemeOptions } from '../types/theme';
|
|
5
|
+
declare type Props = {
|
|
6
|
+
session: Session | undefined;
|
|
7
|
+
width?: string | number;
|
|
8
|
+
height?: string | number;
|
|
9
|
+
customStyles?: ThemeOptions;
|
|
10
|
+
title?: string;
|
|
11
|
+
layoutId: number;
|
|
12
|
+
values?: BusinessData;
|
|
13
|
+
fileName?: string;
|
|
14
|
+
options?: ComponentOptions;
|
|
15
|
+
validateCustom?: (property: string, rowIndex: number | undefined, value: ItemValue, values: BusinessData) => CustomValidationResult;
|
|
16
|
+
onChange?: (property: string, rowIndex: number | undefined, value: ItemValue, values: BusinessData) => void;
|
|
17
|
+
onGenerate?: (logId: string) => void;
|
|
18
|
+
};
|
|
19
|
+
export declare const ReportWebForm: VFC<Props>;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.ReportWebForm = void 0;
|
|
4
|
+
var jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
var react_1 = require("react");
|
|
6
|
+
var targetOrigin_1 = require("../util/targetOrigin");
|
|
7
|
+
var ReportWebForm = function (_a) {
|
|
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
|
+
var iframe = (0, react_1.useRef)(null);
|
|
10
|
+
var handleMessage = (0, react_1.useCallback)(function (e) {
|
|
11
|
+
var _a;
|
|
12
|
+
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
|
+
return;
|
|
14
|
+
}
|
|
15
|
+
var message = e.data;
|
|
16
|
+
var from = message === null || message === void 0 ? void 0 : message.from;
|
|
17
|
+
var action = message === null || message === void 0 ? void 0 : message.action;
|
|
18
|
+
if (from !== 'webform') {
|
|
19
|
+
return;
|
|
20
|
+
}
|
|
21
|
+
if (action === 'onAuthorized') {
|
|
22
|
+
var iframeWindow = (_a = iframe.current) === null || _a === void 0 ? void 0 : _a.contentWindow;
|
|
23
|
+
if (!iframeWindow)
|
|
24
|
+
return;
|
|
25
|
+
iframeWindow.postMessage({
|
|
26
|
+
from: 'webformClient',
|
|
27
|
+
action: 'onShow',
|
|
28
|
+
props: {
|
|
29
|
+
customStyles: customStyles,
|
|
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));
|
|
37
|
+
}
|
|
38
|
+
else if (action === 'validateCustom') {
|
|
39
|
+
var _b = message.payload, property = _b.property, rowIndex = _b.rowIndex, value = _b.value, values_1 = _b.values;
|
|
40
|
+
validateCustom === null || validateCustom === void 0 ? void 0 : validateCustom(property, rowIndex, value, values_1);
|
|
41
|
+
}
|
|
42
|
+
else if (action === 'onChange') {
|
|
43
|
+
var _c = message.payload, property = _c.property, rowIndex = _c.rowIndex, value = _c.value, values_2 = _c.values;
|
|
44
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(property, rowIndex, value, values_2);
|
|
45
|
+
}
|
|
46
|
+
else if (action === 'onGenerate') {
|
|
47
|
+
var logId = message.payload;
|
|
48
|
+
onGenerate === null || onGenerate === void 0 ? void 0 : onGenerate(logId);
|
|
49
|
+
}
|
|
50
|
+
}, [customStyles, fileName, layoutId, onChange, onGenerate, options, session === null || session === void 0 ? void 0 : session.newUrl, title, validateCustom, values]);
|
|
51
|
+
(0, react_1.useEffect)(function () {
|
|
52
|
+
window.addEventListener('message', handleMessage);
|
|
53
|
+
return function () { return window.removeEventListener('message', handleMessage); };
|
|
54
|
+
}, [handleMessage]);
|
|
55
|
+
return (0, jsx_runtime_1.jsx)("iframe", { ref: iframe, id: "webform", src: session === null || session === void 0 ? void 0 : session.newUrl, style: { width: width, height: height, border: 0 } });
|
|
56
|
+
};
|
|
57
|
+
exports.ReportWebForm = ReportWebForm;
|