@sutech_jp/raas-react-client 0.1.42 → 0.1.44

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.
@@ -13,7 +13,8 @@ declare type Props = {
13
13
  options?: ComponentOptions;
14
14
  onChange?: (property: string, rowIndex: number | undefined, value: ItemValue, dataList: BusinessDataList) => void;
15
15
  onChangeRow?: (operation: RowOperation, dataList: BusinessDataList) => void;
16
- onCompleteInput?: (dataList: BusinessDataList) => void;
16
+ onReset?: (property: string, rowIndex: number | undefined, dataList: BusinessDataList) => void;
17
+ onCompleteInput?: (dataList: BusinessDataList) => Promise<void>;
17
18
  onChangeOperating?: (operating: boolean) => void;
18
19
  onBack?: () => void;
19
20
  };
@@ -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 ReportWebFormBulk = 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, layoutId = _a.layoutId, dataList = _a.dataList, extensionSchemaDef = _a.extensionSchemaDef, options = _a.options, onChange = _a.onChange, onChangeRow = _a.onChangeRow, onCompleteInput = _a.onCompleteInput, onChangeOperating = _a.onChangeOperating, onBack = _a.onBack;
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, dataList = _a.dataList, extensionSchemaDef = _a.extensionSchemaDef, options = _a.options, onChange = _a.onChange, onChangeRow = _a.onChangeRow, onReset = _a.onReset, onCompleteInput = _a.onCompleteInput, onChangeOperating = _a.onChangeOperating, 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);
@@ -74,63 +74,89 @@ var ReportWebFormBulk = function (_a) {
74
74
  }, (0, targetOrigin_1.getTargetOrigin)(session === null || session === void 0 ? void 0 : session.newUrl));
75
75
  }, [session === null || session === void 0 ? void 0 : session.newUrl]);
76
76
  var handleMessage = (0, react_1.useCallback)(function (e) { return __awaiter(void 0, void 0, void 0, function () {
77
- var message, from, action, _a, property, rowIndex, value, dataList_1, _b, operation, dataList_2, dataList_3, operating;
78
- return __generator(this, function (_c) {
79
- 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)) {
80
- return [2 /*return*/];
77
+ var message, from, action, _a, property, rowIndex, value, dataList_1, _b, operation, dataList_2, _c, property, rowIndex, dataList_3, dataList_4, operating;
78
+ return __generator(this, function (_d) {
79
+ switch (_d.label) {
80
+ case 0:
81
+ 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)) {
82
+ return [2 /*return*/];
83
+ }
84
+ message = e.data;
85
+ from = message === null || message === void 0 ? void 0 : message.from;
86
+ action = message === null || message === void 0 ? void 0 : message.action;
87
+ if (from !== 'webform') {
88
+ return [2 /*return*/];
89
+ }
90
+ if (!(action === 'onAuthorized')) return [3 /*break*/, 1];
91
+ sendMessage('onShow', {
92
+ customStyles: customStyles,
93
+ layoutId: layoutId,
94
+ dataList: dataList,
95
+ extensionSchemaDef: extensionSchemaDef,
96
+ options: options,
97
+ });
98
+ // 初期化完了状態にする
99
+ setInitialized(true);
100
+ return [3 /*break*/, 7];
101
+ case 1:
102
+ if (!(action === 'onChange')) return [3 /*break*/, 2];
103
+ if (!onChange) {
104
+ return [2 /*return*/];
105
+ }
106
+ _a = message.payload, property = _a.property, rowIndex = _a.rowIndex, value = _a.value, dataList_1 = _a.dataList;
107
+ onChange(property, rowIndex, value, dataList_1);
108
+ return [3 /*break*/, 7];
109
+ case 2:
110
+ if (!(action === 'onChangeRow')) return [3 /*break*/, 3];
111
+ if (!onChangeRow) {
112
+ return [2 /*return*/];
113
+ }
114
+ _b = message.payload, operation = _b.operation, dataList_2 = _b.dataList;
115
+ onChangeRow(operation, dataList_2);
116
+ return [3 /*break*/, 7];
117
+ case 3:
118
+ if (!(action === 'onReset')) return [3 /*break*/, 4];
119
+ if (!onReset) {
120
+ return [2 /*return*/];
121
+ }
122
+ _c = message.payload, property = _c.property, rowIndex = _c.rowIndex, dataList_3 = _c.dataList;
123
+ onReset(property, rowIndex, dataList_3);
124
+ return [3 /*break*/, 7];
125
+ case 4:
126
+ if (!(action === 'onCompleteInput')) return [3 /*break*/, 6];
127
+ if (!onCompleteInput) {
128
+ // 結果メッセージを送信
129
+ sendMessage('onCompleted', {}, message.messageId);
130
+ return [2 /*return*/];
131
+ }
132
+ dataList_4 = message.payload;
133
+ // 入力完了処理を同期待ちする
134
+ return [4 /*yield*/, onCompleteInput(dataList_4)
135
+ // 結果メッセージを送信
136
+ ];
137
+ case 5:
138
+ // 入力完了処理を同期待ちする
139
+ _d.sent();
140
+ // 結果メッセージを送信
141
+ sendMessage('onCompleted', {}, message.messageId);
142
+ return [3 /*break*/, 7];
143
+ case 6:
144
+ if (action === 'onChangeOperating') {
145
+ if (!onChangeOperating) {
146
+ return [2 /*return*/];
147
+ }
148
+ operating = message.payload;
149
+ onChangeOperating(operating);
150
+ }
151
+ else if (action === 'onBack') {
152
+ if (!onBack) {
153
+ return [2 /*return*/];
154
+ }
155
+ onBack();
156
+ }
157
+ _d.label = 7;
158
+ case 7: return [2 /*return*/];
81
159
  }
82
- message = e.data;
83
- from = message === null || message === void 0 ? void 0 : message.from;
84
- action = message === null || message === void 0 ? void 0 : message.action;
85
- if (from !== 'webform') {
86
- return [2 /*return*/];
87
- }
88
- if (action === 'onAuthorized') {
89
- sendMessage('onShow', {
90
- customStyles: customStyles,
91
- layoutId: layoutId,
92
- dataList: dataList,
93
- extensionSchemaDef: extensionSchemaDef,
94
- options: options,
95
- });
96
- // 初期化完了状態にする
97
- setInitialized(true);
98
- }
99
- else if (action === 'onChange') {
100
- if (!onChange) {
101
- return [2 /*return*/];
102
- }
103
- _a = message.payload, property = _a.property, rowIndex = _a.rowIndex, value = _a.value, dataList_1 = _a.dataList;
104
- onChange(property, rowIndex, value, dataList_1);
105
- }
106
- else if (action === 'onChangeRow') {
107
- if (!onChangeRow) {
108
- return [2 /*return*/];
109
- }
110
- _b = message.payload, operation = _b.operation, dataList_2 = _b.dataList;
111
- onChangeRow(operation, dataList_2);
112
- }
113
- else if (action === 'onCompleteInput') {
114
- if (!onCompleteInput) {
115
- return [2 /*return*/];
116
- }
117
- dataList_3 = message.payload;
118
- onCompleteInput(dataList_3);
119
- }
120
- else if (action === 'onChangeOperating') {
121
- if (!onChangeOperating) {
122
- return [2 /*return*/];
123
- }
124
- operating = message.payload;
125
- onChangeOperating(operating);
126
- }
127
- else if (action === 'onBack') {
128
- if (!onBack) {
129
- return [2 /*return*/];
130
- }
131
- onBack();
132
- }
133
- return [2 /*return*/];
134
160
  });
135
161
  }); }, [
136
162
  customStyles,
@@ -141,6 +167,7 @@ var ReportWebFormBulk = function (_a) {
141
167
  onChange,
142
168
  onChangeOperating,
143
169
  onChangeRow,
170
+ onReset,
144
171
  onCompleteInput,
145
172
  options,
146
173
  sendMessage,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sutech_jp/raas-react-client",
3
- "version": "0.1.42",
3
+ "version": "0.1.44",
4
4
  "description": "react client for raas produced by SuTech",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",