@reltio/components 1.4.1128 → 1.4.1129

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.
@@ -181,15 +181,15 @@ var processRequest = function (_a) {
181
181
  break;
182
182
  }
183
183
  case types_1.RequestAction.ALERT: {
184
- window.alert(paramObject.params.text);
184
+ worker.postMessage(__assign({ action: 'response', result: window.alert(paramObject.params.text) }, paramObject.params));
185
185
  break;
186
186
  }
187
187
  case types_1.RequestAction.CONFIRM: {
188
- window.confirm(paramObject.params.text);
188
+ worker.postMessage(__assign({ action: 'response', result: window.confirm(paramObject.params.text) }, paramObject.params));
189
189
  break;
190
190
  }
191
191
  case types_1.RequestAction.PROMPT: {
192
- window.prompt(paramObject.params.text, paramObject.params.defaultText || '');
192
+ worker.postMessage(__assign({ action: 'response', result: window.prompt(paramObject.params.text, paramObject.params.defaultText || '') }, paramObject.params));
193
193
  break;
194
194
  }
195
195
  case types_1.RequestAction.OPEN_WINDOW: {
@@ -41,6 +41,7 @@ export declare type Params = {
41
41
  defaultText?: string;
42
42
  text?: string;
43
43
  html?: string;
44
+ type?: string;
44
45
  };
45
46
  export declare type ProcessRequestParams = {
46
47
  name: RequestAction;
@@ -79,7 +80,8 @@ export declare enum CustomAction {
79
80
  SET_WIDTH = "setWidth",
80
81
  RETURN_PROCESSED_API_RESPONSE = "returnProcessedApiResponse",
81
82
  RETURN_PROCESSED_API_REQUEST = "returnProcessedApiRequest",
82
- REQUEST = "request"
83
+ REQUEST = "request",
84
+ EVENT = "event"
83
85
  }
84
86
  export declare type CustomActionTask = {
85
87
  action: CustomAction;
@@ -39,4 +39,5 @@ var CustomAction;
39
39
  CustomAction["RETURN_PROCESSED_API_RESPONSE"] = "returnProcessedApiResponse";
40
40
  CustomAction["RETURN_PROCESSED_API_REQUEST"] = "returnProcessedApiRequest";
41
41
  CustomAction["REQUEST"] = "request";
42
+ CustomAction["EVENT"] = "event";
42
43
  })(CustomAction = exports.CustomAction || (exports.CustomAction = {}));
@@ -1,5 +1,5 @@
1
1
  import { CustomViewConfig } from '@reltio/mdm-sdk';
2
- export declare const useAPI: (config: CustomViewConfig) => {
2
+ export declare const useAPI: (config?: CustomViewConfig) => {
3
3
  html: HTMLElement;
4
4
  visible: boolean;
5
5
  tooltip: string;
@@ -10,4 +10,5 @@ export declare const useAPI: (config: CustomViewConfig) => {
10
10
  };
11
11
  message: string;
12
12
  onClosePopup: () => void;
13
+ onClick: () => void;
13
14
  };
@@ -41,13 +41,13 @@ var API_1 = require("./API");
41
41
  var helpers_1 = require("./helpers");
42
42
  var types_1 = require("./types");
43
43
  var useAPI = function (config) {
44
- var _a = config.action, files = _a.files, permissions = _a.permissions;
45
- var _b = react_1.useState(), html = _b[0], setHtml = _b[1];
46
- var _c = react_1.useState([]), listenersToReset = _c[0], setListenersToReset = _c[1];
47
- var _d = react_1.useState(true), visible = _d[0], setVisible = _d[1];
48
- var _e = react_1.useState(null), tooltip = _e[0], setTooltip = _e[1];
49
- var _f = react_1.useState(null), customStyles = _f[0], setCustomStyles = _f[1];
50
- var _g = react_1.useState(''), message = _g[0], setMessage = _g[1];
44
+ if (config === void 0) { config = {}; }
45
+ var _a = react_1.useState(), html = _a[0], setHtml = _a[1];
46
+ var _b = react_1.useState([]), listenersToReset = _b[0], setListenersToReset = _b[1];
47
+ var _c = react_1.useState(true), visible = _c[0], setVisible = _c[1];
48
+ var _d = react_1.useState(null), tooltip = _d[0], setTooltip = _d[1];
49
+ var _e = react_1.useState(null), customStyles = _e[0], setCustomStyles = _e[1];
50
+ var _f = react_1.useState(''), message = _f[0], setMessage = _f[1];
51
51
  var dispatch = react_redux_1.useDispatch();
52
52
  var metadata = react_redux_1.useSelector(mdm_module_1.default.selectors.getMetadata) || {};
53
53
  var entity = react_redux_1.useSelector(mdm_module_1.default.selectors.getEntity) || {};
@@ -61,8 +61,9 @@ var useAPI = function (config) {
61
61
  var environment = react_redux_1.useSelector(mdm_module_1.default.selectors.getWorkflowEnvironmentUrl);
62
62
  var qxApi = react_1.useContext(contexts_1.SandboxAPIContext);
63
63
  var workflowCheckPermission = workflow_1.useWorkflowCheckPermission();
64
- var _h = react_redux_1.useSelector(mdm_module_1.default.selectors.getSearchProviderData) || {}, typeSearch = _h.type, search = _h.data;
64
+ var _g = react_redux_1.useSelector(mdm_module_1.default.selectors.getSearchProviderData) || {}, typeSearch = _g.type, search = _g.data;
65
65
  var openSearch = function (search) { return dispatch(mdm_module_1.ui.actions.openSearch(search)); };
66
+ var workerRef = react_1.useRef();
66
67
  var process = function (task, worker, innerText) {
67
68
  if (task) {
68
69
  var handlersToReset_1 = [];
@@ -156,8 +157,7 @@ var useAPI = function (config) {
156
157
  break;
157
158
  }
158
159
  case types_1.CustomAction.REQUEST: {
159
- API_1.processRequest(__assign({ name: task.params.name, paramObject: task, permissions: permissions,
160
- worker: worker,
160
+ API_1.processRequest(__assign({ name: task.params.name, paramObject: task, permissions: config.action.permissions, worker: worker,
161
161
  metadata: metadata, config: config, user: user,
162
162
  apiPath: apiPath,
163
163
  tenant: tenant,
@@ -172,21 +172,32 @@ var useAPI = function (config) {
172
172
  }
173
173
  };
174
174
  react_1.useEffect(function () {
175
- var worker = mdm_sdk_1.initializeWebWorker(workerUrl, files, process);
176
- return function () {
177
- worker.terminate();
178
- };
179
- }, []);
175
+ if (!mdm_sdk_1.isEmptyValue(config.action)) {
176
+ workerRef.current = mdm_sdk_1.initializeWebWorker(workerUrl, config.action.files, process);
177
+ return function () {
178
+ workerRef.current.terminate();
179
+ };
180
+ }
181
+ }, [config]);
180
182
  react_1.useEffect(function () { return function () {
181
183
  listenersToReset.forEach(function (listener) { return listener(); });
182
184
  }; }, [listenersToReset]);
185
+ var onClick = react_1.useCallback(function () {
186
+ var _a;
187
+ (_a = workerRef.current) === null || _a === void 0 ? void 0 : _a.postMessage({
188
+ action: 'event',
189
+ type: 'execute',
190
+ data: null
191
+ });
192
+ }, [config]);
183
193
  return {
184
194
  html: html,
185
195
  visible: visible,
186
196
  tooltip: tooltip,
187
197
  customStyles: customStyles,
188
198
  message: message,
189
- onClosePopup: function () { return setMessage(''); }
199
+ onClosePopup: function () { return setMessage(''); },
200
+ onClick: onClick
190
201
  };
191
202
  };
192
203
  exports.useAPI = useAPI;
@@ -178,15 +178,15 @@ export var processRequest = function (_a) {
178
178
  break;
179
179
  }
180
180
  case RequestAction.ALERT: {
181
- window.alert(paramObject.params.text);
181
+ worker.postMessage(__assign({ action: 'response', result: window.alert(paramObject.params.text) }, paramObject.params));
182
182
  break;
183
183
  }
184
184
  case RequestAction.CONFIRM: {
185
- window.confirm(paramObject.params.text);
185
+ worker.postMessage(__assign({ action: 'response', result: window.confirm(paramObject.params.text) }, paramObject.params));
186
186
  break;
187
187
  }
188
188
  case RequestAction.PROMPT: {
189
- window.prompt(paramObject.params.text, paramObject.params.defaultText || '');
189
+ worker.postMessage(__assign({ action: 'response', result: window.prompt(paramObject.params.text, paramObject.params.defaultText || '') }, paramObject.params));
190
190
  break;
191
191
  }
192
192
  case RequestAction.OPEN_WINDOW: {
@@ -41,6 +41,7 @@ export declare type Params = {
41
41
  defaultText?: string;
42
42
  text?: string;
43
43
  html?: string;
44
+ type?: string;
44
45
  };
45
46
  export declare type ProcessRequestParams = {
46
47
  name: RequestAction;
@@ -79,7 +80,8 @@ export declare enum CustomAction {
79
80
  SET_WIDTH = "setWidth",
80
81
  RETURN_PROCESSED_API_RESPONSE = "returnProcessedApiResponse",
81
82
  RETURN_PROCESSED_API_REQUEST = "returnProcessedApiRequest",
82
- REQUEST = "request"
83
+ REQUEST = "request",
84
+ EVENT = "event"
83
85
  }
84
86
  export declare type CustomActionTask = {
85
87
  action: CustomAction;
@@ -36,4 +36,5 @@ export var CustomAction;
36
36
  CustomAction["RETURN_PROCESSED_API_RESPONSE"] = "returnProcessedApiResponse";
37
37
  CustomAction["RETURN_PROCESSED_API_REQUEST"] = "returnProcessedApiRequest";
38
38
  CustomAction["REQUEST"] = "request";
39
+ CustomAction["EVENT"] = "event";
39
40
  })(CustomAction || (CustomAction = {}));
@@ -1,5 +1,5 @@
1
1
  import { CustomViewConfig } from '@reltio/mdm-sdk';
2
- export declare const useAPI: (config: CustomViewConfig) => {
2
+ export declare const useAPI: (config?: CustomViewConfig) => {
3
3
  html: HTMLElement;
4
4
  visible: boolean;
5
5
  tooltip: string;
@@ -10,4 +10,5 @@ export declare const useAPI: (config: CustomViewConfig) => {
10
10
  };
11
11
  message: string;
12
12
  onClosePopup: () => void;
13
+ onClick: () => void;
13
14
  };
@@ -9,23 +9,23 @@ var __assign = (this && this.__assign) || function () {
9
9
  };
10
10
  return __assign.apply(this, arguments);
11
11
  };
12
- import { useContext, useEffect, useState } from 'react';
12
+ import { useCallback, useContext, useEffect, useRef, useState } from 'react';
13
13
  import { useDispatch, useSelector } from 'react-redux';
14
14
  import mdmModule, { ui } from '@reltio/mdm-module';
15
- import { initializeWebWorker } from '@reltio/mdm-sdk';
15
+ import { initializeWebWorker, isEmptyValue } from '@reltio/mdm-sdk';
16
16
  import { useWorkflowCheckPermission } from '../../components/workflow';
17
17
  import { SandboxAPIContext } from '../../contexts';
18
18
  import { processRequest } from './API';
19
19
  import { getWorkerURL } from './helpers';
20
20
  import { CustomAction } from './types';
21
21
  export var useAPI = function (config) {
22
- var _a = config.action, files = _a.files, permissions = _a.permissions;
23
- var _b = useState(), html = _b[0], setHtml = _b[1];
24
- var _c = useState([]), listenersToReset = _c[0], setListenersToReset = _c[1];
25
- var _d = useState(true), visible = _d[0], setVisible = _d[1];
26
- var _e = useState(null), tooltip = _e[0], setTooltip = _e[1];
27
- var _f = useState(null), customStyles = _f[0], setCustomStyles = _f[1];
28
- var _g = useState(''), message = _g[0], setMessage = _g[1];
22
+ if (config === void 0) { config = {}; }
23
+ var _a = useState(), html = _a[0], setHtml = _a[1];
24
+ var _b = useState([]), listenersToReset = _b[0], setListenersToReset = _b[1];
25
+ var _c = useState(true), visible = _c[0], setVisible = _c[1];
26
+ var _d = useState(null), tooltip = _d[0], setTooltip = _d[1];
27
+ var _e = useState(null), customStyles = _e[0], setCustomStyles = _e[1];
28
+ var _f = useState(''), message = _f[0], setMessage = _f[1];
29
29
  var dispatch = useDispatch();
30
30
  var metadata = useSelector(mdmModule.selectors.getMetadata) || {};
31
31
  var entity = useSelector(mdmModule.selectors.getEntity) || {};
@@ -39,8 +39,9 @@ export var useAPI = function (config) {
39
39
  var environment = useSelector(mdmModule.selectors.getWorkflowEnvironmentUrl);
40
40
  var qxApi = useContext(SandboxAPIContext);
41
41
  var workflowCheckPermission = useWorkflowCheckPermission();
42
- var _h = useSelector(mdmModule.selectors.getSearchProviderData) || {}, typeSearch = _h.type, search = _h.data;
42
+ var _g = useSelector(mdmModule.selectors.getSearchProviderData) || {}, typeSearch = _g.type, search = _g.data;
43
43
  var openSearch = function (search) { return dispatch(ui.actions.openSearch(search)); };
44
+ var workerRef = useRef();
44
45
  var process = function (task, worker, innerText) {
45
46
  if (task) {
46
47
  var handlersToReset_1 = [];
@@ -134,8 +135,7 @@ export var useAPI = function (config) {
134
135
  break;
135
136
  }
136
137
  case CustomAction.REQUEST: {
137
- processRequest(__assign({ name: task.params.name, paramObject: task, permissions: permissions,
138
- worker: worker,
138
+ processRequest(__assign({ name: task.params.name, paramObject: task, permissions: config.action.permissions, worker: worker,
139
139
  metadata: metadata, config: config, user: user,
140
140
  apiPath: apiPath,
141
141
  tenant: tenant,
@@ -150,20 +150,31 @@ export var useAPI = function (config) {
150
150
  }
151
151
  };
152
152
  useEffect(function () {
153
- var worker = initializeWebWorker(workerUrl, files, process);
154
- return function () {
155
- worker.terminate();
156
- };
157
- }, []);
153
+ if (!isEmptyValue(config.action)) {
154
+ workerRef.current = initializeWebWorker(workerUrl, config.action.files, process);
155
+ return function () {
156
+ workerRef.current.terminate();
157
+ };
158
+ }
159
+ }, [config]);
158
160
  useEffect(function () { return function () {
159
161
  listenersToReset.forEach(function (listener) { return listener(); });
160
162
  }; }, [listenersToReset]);
163
+ var onClick = useCallback(function () {
164
+ var _a;
165
+ (_a = workerRef.current) === null || _a === void 0 ? void 0 : _a.postMessage({
166
+ action: 'event',
167
+ type: 'execute',
168
+ data: null
169
+ });
170
+ }, [config]);
161
171
  return {
162
172
  html: html,
163
173
  visible: visible,
164
174
  tooltip: tooltip,
165
175
  customStyles: customStyles,
166
176
  message: message,
167
- onClosePopup: function () { return setMessage(''); }
177
+ onClosePopup: function () { return setMessage(''); },
178
+ onClick: onClick
168
179
  };
169
180
  };
package/package.json CHANGED
@@ -1,14 +1,14 @@
1
1
  {
2
2
  "name": "@reltio/components",
3
- "version": "1.4.1128",
3
+ "version": "1.4.1129",
4
4
  "license": "SEE LICENSE IN LICENSE FILE",
5
5
  "main": "./cjs/index.js",
6
6
  "module": "./esm/index.js",
7
7
  "dependencies": {
8
8
  "@date-io/moment": "^1.3.5",
9
9
  "@react-google-maps/api": "2.7.0",
10
- "@reltio/mdm-module": "^1.4.1128",
11
- "@reltio/mdm-sdk": "^1.4.1128",
10
+ "@reltio/mdm-module": "^1.4.1129",
11
+ "@reltio/mdm-sdk": "^1.4.1129",
12
12
  "classnames": "^2.2.5",
13
13
  "d3-cloud": "^1.2.5",
14
14
  "d3-geo": "^2.0.1",