@sutech_jp/datatraveler-react-client 0.1.22 → 0.1.26

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.
@@ -0,0 +1,17 @@
1
+ import { VFC } from 'react';
2
+ import { Session } from './types';
3
+ import { ThemeOptions } from './types/theme';
4
+ import { BusinessData, ItemValue } from './types/webform';
5
+ declare type Props = {
6
+ session: Session | undefined;
7
+ width?: string | number;
8
+ height?: string | number;
9
+ customStyles?: ThemeOptions;
10
+ application: string;
11
+ schema: string;
12
+ dataIds: string[];
13
+ layoutId: number;
14
+ onChange?: (property: string, rowIndex: number | undefined, value: ItemValue, values: BusinessData) => void;
15
+ };
16
+ export declare const DataTravelerBulkWebForm: VFC<Props>;
17
+ export {};
@@ -0,0 +1,97 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ var __generator = (this && this.__generator) || function (thisArg, body) {
12
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
13
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
14
+ function verb(n) { return function (v) { return step([n, v]); }; }
15
+ function step(op) {
16
+ if (f) throw new TypeError("Generator is already executing.");
17
+ while (_) try {
18
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
19
+ if (y = 0, t) op = [op[0] & 2, t.value];
20
+ switch (op[0]) {
21
+ case 0: case 1: t = op; break;
22
+ case 4: _.label++; return { value: op[1], done: false };
23
+ case 5: _.label++; y = op[1]; op = [0]; continue;
24
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
25
+ default:
26
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
27
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
28
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
29
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
30
+ if (t[2]) _.ops.pop();
31
+ _.trys.pop(); continue;
32
+ }
33
+ op = body.call(thisArg, _);
34
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
35
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
36
+ }
37
+ };
38
+ Object.defineProperty(exports, "__esModule", { value: true });
39
+ exports.DataTravelerBulkWebForm = void 0;
40
+ var jsx_runtime_1 = require("react/jsx-runtime");
41
+ var react_1 = require("react");
42
+ var targetOrigin_1 = require("./util/targetOrigin");
43
+ var DataTravelerBulkWebForm = function (_a) {
44
+ 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, application = _a.application, schema = _a.schema, dataIds = _a.dataIds, layoutId = _a.layoutId, onChange = _a.onChange;
45
+ var iframe = (0, react_1.useRef)(null);
46
+ var sendMessage = (0, react_1.useCallback)(function (action, props, requestId) {
47
+ var _a;
48
+ var iframeWindow = (_a = iframe.current) === null || _a === void 0 ? void 0 : _a.contentWindow;
49
+ if (!iframeWindow)
50
+ return;
51
+ iframeWindow.postMessage({
52
+ from: 'dataTravelerBulkWebformClient',
53
+ action: action,
54
+ props: props,
55
+ messageId: requestId,
56
+ }, (0, targetOrigin_1.getTargetOrigin)(session === null || session === void 0 ? void 0 : session.newUrl));
57
+ }, [session === null || session === void 0 ? void 0 : session.newUrl]);
58
+ var handleMessage = (0, react_1.useCallback)(function (e) { return __awaiter(void 0, void 0, void 0, function () {
59
+ var message, from, action, _a, property, rowIndex, value, values;
60
+ return __generator(this, function (_b) {
61
+ 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)) {
62
+ return [2 /*return*/];
63
+ }
64
+ message = e.data;
65
+ from = message === null || message === void 0 ? void 0 : message.from;
66
+ action = message === null || message === void 0 ? void 0 : message.action;
67
+ if (from !== 'dataTravelerBulkWebform') {
68
+ return [2 /*return*/];
69
+ }
70
+ if (action === 'onAuthorized') {
71
+ sendMessage('onShow', {
72
+ width: width,
73
+ height: height,
74
+ customStyles: customStyles,
75
+ application: application,
76
+ schema: schema,
77
+ dataIds: dataIds,
78
+ layoutId: layoutId,
79
+ });
80
+ }
81
+ else if (action === 'onChange') {
82
+ if (!onChange) {
83
+ return [2 /*return*/];
84
+ }
85
+ _a = message.payload, property = _a.property, rowIndex = _a.rowIndex, value = _a.value, values = _a.values;
86
+ onChange(property, rowIndex, value, values);
87
+ }
88
+ return [2 /*return*/];
89
+ });
90
+ }); }, [customStyles, onChange, sendMessage, session === null || session === void 0 ? void 0 : session.newUrl, width, height, application, schema, dataIds, layoutId]);
91
+ (0, react_1.useEffect)(function () {
92
+ window.addEventListener('message', handleMessage);
93
+ return function () { return window.removeEventListener('message', handleMessage); };
94
+ }, [handleMessage]);
95
+ return (0, jsx_runtime_1.jsx)("iframe", { ref: iframe, id: "dataTravelerBulkWebForm", src: session === null || session === void 0 ? void 0 : session.newUrl, style: { width: width, height: height, border: 0 } });
96
+ };
97
+ exports.DataTravelerBulkWebForm = DataTravelerBulkWebForm;
package/dist/index.d.ts CHANGED
@@ -1,2 +1,3 @@
1
1
  export * from './DataTravelerImport';
2
+ export * from './DataTravelerBulkWebForm';
2
3
  export * from './types';
package/dist/index.js CHANGED
@@ -15,4 +15,5 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./DataTravelerImport"), exports);
18
+ __exportStar(require("./DataTravelerBulkWebForm"), exports);
18
19
  __exportStar(require("./types"), exports);
@@ -0,0 +1,62 @@
1
+ export declare type ItemValue = string | number | boolean | Date | null;
2
+ export declare type ObjectValue = {
3
+ [key: string]: ItemValue | ObjectValue | ArrayValue;
4
+ };
5
+ export declare type ArrayValue = ObjectValue[];
6
+ export declare type BusinessData = ObjectValue;
7
+ export declare type ComponentOptions = {
8
+ title?: string;
9
+ requiredIndicator?: 'simple' | 'filled' | 'outlined';
10
+ showReportGenerationButton?: boolean;
11
+ showBackButton?: boolean;
12
+ };
13
+ export declare type CustomValidationResult = {
14
+ type: 'custom';
15
+ property: string;
16
+ error: boolean;
17
+ message?: string;
18
+ };
19
+ export declare type ExtensionSchemaDef = {
20
+ container: ExtensionSchemaContainer;
21
+ properties: ExtensionSchemaProperty[];
22
+ };
23
+ export declare type ExtensionSchemaContainer = {
24
+ property: string;
25
+ caption: string;
26
+ };
27
+ export declare type ExtensionSchemaProperty = TextProperty | NumberProperty | DateProperty | DatetimeProperty | BooleanProperty;
28
+ export declare type PropertyBase = {
29
+ property: string;
30
+ caption: string;
31
+ required?: boolean;
32
+ };
33
+ export declare type TextProperty = {
34
+ type: 'text';
35
+ minLength?: number;
36
+ maxLength?: number;
37
+ } & PropertyBase;
38
+ export declare type NumberProperty = {
39
+ type: 'number';
40
+ min?: number;
41
+ max?: number;
42
+ minAcceptEqual?: boolean;
43
+ maxAcceptEqual?: boolean;
44
+ precision?: number;
45
+ } & PropertyBase;
46
+ export declare type DateProperty = {
47
+ type: 'date';
48
+ min?: Date;
49
+ max?: Date;
50
+ minAcceptEqual?: boolean;
51
+ maxAcceptEqual?: boolean;
52
+ } & PropertyBase;
53
+ export declare type DatetimeProperty = {
54
+ type: 'datetime';
55
+ min?: Date;
56
+ max?: Date;
57
+ minAcceptEqual?: boolean;
58
+ maxAcceptEqual?: boolean;
59
+ } & PropertyBase;
60
+ export declare type BooleanProperty = {
61
+ type: 'boolean';
62
+ } & PropertyBase;
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sutech_jp/datatraveler-react-client",
3
- "version": "0.1.22",
3
+ "version": "0.1.26",
4
4
  "description": "react client for data traveler produced by SuTech",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",