@sutech_jp/raas-react-client 0.1.31 → 0.1.33

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.
@@ -1,4 +1,3 @@
1
- import { ReactNode } from 'react';
2
1
  export declare type ItemValue = string | number | boolean | Date | null;
3
2
  export declare type ObjectValue = {
4
3
  [key: string]: ItemValue | ObjectValue | ArrayValue;
@@ -6,10 +5,14 @@ export declare type ObjectValue = {
6
5
  export declare type ArrayValue = ObjectValue[];
7
6
  export declare type BusinessData = ObjectValue;
8
7
  export declare type ComponentOptions = {
9
- requiredMark?: ReactNode;
10
- showReportOutputButton?: boolean;
8
+ title?: string;
9
+ requiredIndicator?: 'simple' | 'filled' | 'outlined';
10
+ showReportGenerationButton?: boolean;
11
+ showBackButton?: boolean;
11
12
  };
12
13
  export declare type CustomValidationResult = {
14
+ type: 'custom';
15
+ property: string;
13
16
  error: boolean;
14
17
  message?: string;
15
18
  };
@@ -7,14 +7,15 @@ declare type Props = {
7
7
  width?: string | number;
8
8
  height?: string | number;
9
9
  customStyles?: ThemeOptions;
10
- title?: string;
11
10
  layoutId: number;
12
11
  values?: BusinessData;
13
12
  fileName?: string;
14
13
  options?: ComponentOptions;
15
14
  validate?: (property: string, rowIndex: number | undefined, value: ItemValue, values: BusinessData) => Promise<CustomValidationResult>;
15
+ validateAll?: (values: BusinessData) => Promise<CustomValidationResult[]>;
16
16
  onChange?: (property: string, rowIndex: number | undefined, value: ItemValue, values: BusinessData) => void;
17
17
  onGenerate?: (logId: string) => void;
18
+ onBack?: () => void;
18
19
  };
19
20
  export declare const ReportWebForm: VFC<Props>;
20
21
  export {};
@@ -57,7 +57,7 @@ var jsx_runtime_1 = require("react/jsx-runtime");
57
57
  var react_1 = require("react");
58
58
  var targetOrigin_1 = require("../util/targetOrigin");
59
59
  var ReportWebForm = function (_a) {
60
- 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, validate = _a.validate, onChange = _a.onChange, onGenerate = _a.onGenerate;
60
+ 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, layoutId = _a.layoutId, values = _a.values, fileName = _a.fileName, options = _a.options, validate = _a.validate, validateAll = _a.validateAll, onChange = _a.onChange, onGenerate = _a.onGenerate, onBack = _a.onBack;
61
61
  var _d = __read((0, react_1.useState)(false), 2), initialized = _d[0], setInitialized = _d[1];
62
62
  var prevInitialized = (0, react_1.useRef)(false);
63
63
  var iframe = (0, react_1.useRef)(null);
@@ -87,7 +87,7 @@ var ReportWebForm = function (_a) {
87
87
  prevInitialized.current = initialized;
88
88
  }, [initialized, values, sendMessage]);
89
89
  var handleMessage = (0, react_1.useCallback)(function (e) { return __awaiter(void 0, void 0, void 0, function () {
90
- var message, from, action, _a, property, rowIndex, value, values_1, result, _b, property, rowIndex, value, values_2, logId;
90
+ var message, from, action, _a, property, rowIndex, value, values_1, result, values_2, results, _b, property, rowIndex, value, values_3, logId;
91
91
  return __generator(this, function (_c) {
92
92
  switch (_c.label) {
93
93
  case 0:
@@ -103,7 +103,6 @@ var ReportWebForm = function (_a) {
103
103
  if (!(action === 'onAuthorized')) return [3 /*break*/, 1];
104
104
  sendMessage('onShow', {
105
105
  customStyles: customStyles,
106
- title: title,
107
106
  layoutId: layoutId,
108
107
  values: values,
109
108
  fileName: fileName,
@@ -111,7 +110,7 @@ var ReportWebForm = function (_a) {
111
110
  });
112
111
  // 初期化完了状態にする
113
112
  setInitialized(true);
114
- return [3 /*break*/, 4];
113
+ return [3 /*break*/, 6];
115
114
  case 1:
116
115
  if (!(action === 'onValidate')) return [3 /*break*/, 3];
117
116
  if (!validate) {
@@ -125,14 +124,28 @@ var ReportWebForm = function (_a) {
125
124
  result = _c.sent();
126
125
  // バリデーション結果を送信
127
126
  sendMessage('onValidated', result, message.messageId);
128
- return [3 /*break*/, 4];
127
+ return [3 /*break*/, 6];
129
128
  case 3:
129
+ if (!(action === 'onValidateAll')) return [3 /*break*/, 5];
130
+ if (!validateAll) {
131
+ return [2 /*return*/];
132
+ }
133
+ values_2 = message.payload.values;
134
+ return [4 /*yield*/, validateAll(values_2)
135
+ // バリデーション結果を送信
136
+ ];
137
+ case 4:
138
+ results = _c.sent();
139
+ // バリデーション結果を送信
140
+ sendMessage('onValidatedAll', results, message.messageId);
141
+ return [3 /*break*/, 6];
142
+ case 5:
130
143
  if (action === 'onChange') {
131
144
  if (!onChange) {
132
145
  return [2 /*return*/];
133
146
  }
134
- _b = message.payload, property = _b.property, rowIndex = _b.rowIndex, value = _b.value, values_2 = _b.values;
135
- onChange(property, rowIndex, value, values_2);
147
+ _b = message.payload, property = _b.property, rowIndex = _b.rowIndex, value = _b.value, values_3 = _b.values;
148
+ onChange(property, rowIndex, value, values_3);
136
149
  }
137
150
  else if (action === 'onGenerate') {
138
151
  if (!onGenerate) {
@@ -141,21 +154,28 @@ var ReportWebForm = function (_a) {
141
154
  logId = message.payload;
142
155
  onGenerate(logId);
143
156
  }
144
- _c.label = 4;
145
- case 4: return [2 /*return*/];
157
+ else if (action === 'onBack') {
158
+ if (!onBack) {
159
+ return [2 /*return*/];
160
+ }
161
+ onBack();
162
+ }
163
+ _c.label = 6;
164
+ case 6: return [2 /*return*/];
146
165
  }
147
166
  });
148
167
  }); }, [
149
168
  customStyles,
150
169
  fileName,
151
170
  layoutId,
171
+ onBack,
152
172
  onChange,
153
173
  onGenerate,
154
174
  options,
155
175
  sendMessage,
156
176
  session === null || session === void 0 ? void 0 : session.newUrl,
157
- title,
158
177
  validate,
178
+ validateAll,
159
179
  values,
160
180
  ]);
161
181
  (0, react_1.useEffect)(function () {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sutech_jp/raas-react-client",
3
- "version": "0.1.31",
3
+ "version": "0.1.33",
4
4
  "description": "react client for raas produced by SuTech",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",