@legalplace/wizardx-core 4.26.1 → 4.28.0
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/components/SmartScript.d.ts +1 -1
- package/dist/components/SmartScript.js +25 -8
- package/dist/componentsConnectors/connectVariable.d.ts +7 -0
- package/dist/componentsConnectors/connectVariable.js +15 -9
- package/dist/redux/middlewares/smartscriptMiddleware.js +16 -7
- package/dist/redux/selectors/library.d.ts +1 -0
- package/dist/redux/selectors/references.d.ts +3 -1
- package/dist/redux/selectors/references.js +9 -0
- package/package.json +2 -2
|
@@ -23,7 +23,7 @@ declare global {
|
|
|
23
23
|
hideVariable: typeof SmartScriptStore.hideVariable;
|
|
24
24
|
displayVariable: typeof SmartScriptStore.displayVariable;
|
|
25
25
|
moment: typeof moment;
|
|
26
|
-
triggerListeners: (type: "option" | "variable", id: number, inputs: StateType.Inputs) => Action[]
|
|
26
|
+
triggerListeners: (type: "option" | "variable", id: number, inputs: StateType.Inputs) => Promise<Action[]>;
|
|
27
27
|
initTriggers: (callback: TInitTriggersCallback, inputs: StateType.Inputs, newInstance: boolean) => void;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
2
11
|
import { useEffect, useState } from "react";
|
|
3
12
|
import { useParams } from "react-router-dom";
|
|
@@ -78,20 +87,28 @@ const SmartScriptComponent = ({ inpiActivities = [] }) => {
|
|
|
78
87
|
setIsNewInstance(newInstance);
|
|
79
88
|
}
|
|
80
89
|
};
|
|
81
|
-
window.triggerListeners = (type, id, inputs) => {
|
|
90
|
+
window.triggerListeners = (type, id, inputs) => __awaiter(void 0, void 0, void 0, function* () {
|
|
82
91
|
const hooks = SmartScriptStore.hooks[type === "option" ? "options" : "variables"];
|
|
83
92
|
const listeners = hooks[id];
|
|
84
93
|
if (Array.isArray(listeners)) {
|
|
85
94
|
SmartScriptStore.inputs = inputs;
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
95
|
+
const promises = listeners.map((_cb) => __awaiter(void 0, void 0, void 0, function* () {
|
|
96
|
+
try {
|
|
97
|
+
if (typeof _cb === "function") {
|
|
98
|
+
return yield _cb();
|
|
99
|
+
}
|
|
100
|
+
console.warn("Invalid listener detected:", _cb);
|
|
101
|
+
return Promise.resolve();
|
|
102
|
+
}
|
|
103
|
+
catch (e) {
|
|
104
|
+
console.error("SmartScript (triggerListener) error:", e.message);
|
|
105
|
+
return Promise.resolve();
|
|
106
|
+
}
|
|
107
|
+
}));
|
|
108
|
+
yield Promise.all(promises);
|
|
92
109
|
}
|
|
93
110
|
return SmartScriptStore.grabActions();
|
|
94
|
-
};
|
|
111
|
+
});
|
|
95
112
|
return _jsx(_Fragment, { children: smartScriptLoaded ? "SmartScript" : "Loading..." }, void 0);
|
|
96
113
|
};
|
|
97
114
|
const mapStateToProps = () => {
|
|
@@ -4,6 +4,11 @@ export declare type ConnectVariableOwnProps = {
|
|
|
4
4
|
id: number;
|
|
5
5
|
index: number;
|
|
6
6
|
};
|
|
7
|
+
declare type AutocompleteParent = {
|
|
8
|
+
id?: number;
|
|
9
|
+
condition?: boolean;
|
|
10
|
+
value?: string | number;
|
|
11
|
+
};
|
|
7
12
|
export declare type ConnectVariableMapProps = {
|
|
8
13
|
id: number;
|
|
9
14
|
index: number;
|
|
@@ -21,6 +26,7 @@ export declare type ConnectVariableMapProps = {
|
|
|
21
26
|
autocompleteDataset?: AutocompleteDatasetType;
|
|
22
27
|
display: boolean;
|
|
23
28
|
meta: VariableV3;
|
|
29
|
+
autocompleteParents?: AutocompleteParent[];
|
|
24
30
|
};
|
|
25
31
|
export declare type ConnectVariableDispatchProps = {
|
|
26
32
|
updateVariable: (value: string | number) => void;
|
|
@@ -31,3 +37,4 @@ export declare const connectVariable: <AdditionnalProps = {}>(Component: import(
|
|
|
31
37
|
} | undefined) => ((props: any) => JSX.Element) | import("react-redux").ConnectedComponent<import("react").ComponentClass<any, any> | import("react").FunctionComponent<any>, import("react-redux").Omit<any, never> & ConnectVariableOwnProps & AdditionnalProps & {
|
|
32
38
|
store?: import("redux").Store<any, import("redux").AnyAction> | undefined;
|
|
33
39
|
}>;
|
|
40
|
+
export {};
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { componentConnector } from "./connector/componentConnector";
|
|
2
2
|
import { isStepAvailable } from "../redux/selectors/app";
|
|
3
|
-
import { selectVariableParents } from "../redux/selectors/references";
|
|
3
|
+
import { selectOptionReference, selectVariableParents, selectVariablesReference, } from "../redux/selectors/references";
|
|
4
4
|
import { parseRawWithRelatedVariables, parseVariableLabel, } from "../helpers/outputsParsing";
|
|
5
5
|
import { selectAutocompleteDataset, selectIsVariableDisabledByIndex, selectLinkedVariables, selectVariableDisabledTooltipByIndex, } from "../redux";
|
|
6
6
|
export const canVariableDisplay = (id, index, selectors) => {
|
|
@@ -35,6 +35,16 @@ const stateToProps = (selectors) => (state, ownProps) => {
|
|
|
35
35
|
const mandatoryValidated = selectMandatoryVariableByIndex(id, index);
|
|
36
36
|
const mandatoryIgnore = selectors.selectMandatoryIgnore();
|
|
37
37
|
const parentOptionId = selectVariableParents(id)[0];
|
|
38
|
+
const optionData = selectOptionReference(parentOptionId);
|
|
39
|
+
const variablesSection = selectVariablesReference(optionData.variables);
|
|
40
|
+
const autocompleteParents = variablesSection
|
|
41
|
+
.filter((variableItem) => variableItem.type === "autocomplete" &&
|
|
42
|
+
Object.values((variableItem === null || variableItem === void 0 ? void 0 : variableItem.linkedVariables) || []).includes(id))
|
|
43
|
+
.map((autoParent) => ({
|
|
44
|
+
id: autoParent.id,
|
|
45
|
+
value: selectVariableInputByIndex(autoParent.id, index) || "",
|
|
46
|
+
condition: selectVariableConditionValue(autoParent.id, index),
|
|
47
|
+
}));
|
|
38
48
|
const validatorMessage = typeof ((_a = variable.validator) === null || _a === void 0 ? void 0 : _a.message) === "string"
|
|
39
49
|
? parseRawWithRelatedVariables(variable.validator.message, parentOptionId, index)
|
|
40
50
|
: "";
|
|
@@ -44,14 +54,11 @@ const stateToProps = (selectors) => (state, ownProps) => {
|
|
|
44
54
|
const warning = variable.warning
|
|
45
55
|
? parseRawWithRelatedVariables(variable.warning, parentOptionId, index, undefined, "________________")
|
|
46
56
|
: undefined;
|
|
47
|
-
return {
|
|
48
|
-
id,
|
|
57
|
+
return Object.assign({ id,
|
|
49
58
|
index,
|
|
50
59
|
label,
|
|
51
|
-
type,
|
|
52
|
-
|
|
53
|
-
warning }),
|
|
54
|
-
value,
|
|
60
|
+
type, meta: Object.assign(Object.assign(Object.assign({}, variable), (selectValues && { selectValues })), { helper,
|
|
61
|
+
warning }), value,
|
|
55
62
|
condition,
|
|
56
63
|
validator,
|
|
57
64
|
validatorMessage,
|
|
@@ -61,8 +68,7 @@ const stateToProps = (selectors) => (state, ownProps) => {
|
|
|
61
68
|
disabled,
|
|
62
69
|
disabledTooltip,
|
|
63
70
|
autocompleteDataset,
|
|
64
|
-
display,
|
|
65
|
-
};
|
|
71
|
+
display }, ((autocompleteParents === null || autocompleteParents === void 0 ? void 0 : autocompleteParents.length) && { autocompleteParents }));
|
|
66
72
|
};
|
|
67
73
|
const dispatchToProps = (actions) => (dispatch, ownProps) => ({
|
|
68
74
|
updateVariable: (value) => dispatch(actions.updateVariableAction(ownProps.id, value, ownProps.index)),
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
1
10
|
import cloneDeep from "lodash/cloneDeep";
|
|
2
11
|
import { generatePath } from "react-router-dom";
|
|
3
12
|
import { getConfig } from "../../config";
|
|
@@ -60,14 +69,14 @@ const watchResetState = (mpi, next, action) => {
|
|
|
60
69
|
iframe = null;
|
|
61
70
|
}
|
|
62
71
|
};
|
|
63
|
-
const watchUpdateOptionInput = (mpi, next, action) => {
|
|
72
|
+
const watchUpdateOptionInput = (mpi, next, action) => __awaiter(void 0, void 0, void 0, function* () {
|
|
64
73
|
var _a;
|
|
65
74
|
next(action);
|
|
66
75
|
const state = mpi.getState();
|
|
67
76
|
const { id } = action;
|
|
68
77
|
if (state.smartscript.triggers.options.includes(id)) {
|
|
69
78
|
try {
|
|
70
|
-
const actions = (_a = iframe === null || iframe === void 0 ? void 0 : iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.triggerListeners("option", id, cloneDeep(state.inputs));
|
|
79
|
+
const actions = yield ((_a = iframe === null || iframe === void 0 ? void 0 : iframe.contentWindow) === null || _a === void 0 ? void 0 : _a.triggerListeners("option", id, cloneDeep(state.inputs)));
|
|
71
80
|
if (Array.isArray(actions)) {
|
|
72
81
|
actions.forEach((_action) => {
|
|
73
82
|
mpi.dispatch(_action);
|
|
@@ -78,15 +87,15 @@ const watchUpdateOptionInput = (mpi, next, action) => {
|
|
|
78
87
|
console.error(e);
|
|
79
88
|
}
|
|
80
89
|
}
|
|
81
|
-
};
|
|
82
|
-
const watchUpdateVariableInput = (mpi, next, action) => {
|
|
83
|
-
var
|
|
90
|
+
});
|
|
91
|
+
const watchUpdateVariableInput = (mpi, next, action) => __awaiter(void 0, void 0, void 0, function* () {
|
|
92
|
+
var _b;
|
|
84
93
|
next(action);
|
|
85
94
|
const state = mpi.getState();
|
|
86
95
|
const { id } = action;
|
|
87
96
|
if (state.smartscript.triggers.variables.includes(id)) {
|
|
88
97
|
try {
|
|
89
|
-
const actions = (
|
|
98
|
+
const actions = yield ((_b = iframe === null || iframe === void 0 ? void 0 : iframe.contentWindow) === null || _b === void 0 ? void 0 : _b.triggerListeners("variable", id, cloneDeep(state.inputs)));
|
|
90
99
|
if (Array.isArray(actions)) {
|
|
91
100
|
actions.forEach((_action) => {
|
|
92
101
|
mpi.dispatch(_action);
|
|
@@ -97,7 +106,7 @@ const watchUpdateVariableInput = (mpi, next, action) => {
|
|
|
97
106
|
console.error(e);
|
|
98
107
|
}
|
|
99
108
|
}
|
|
100
|
-
};
|
|
109
|
+
});
|
|
101
110
|
const watchInitInputs = (mpi, next, action) => {
|
|
102
111
|
next(action);
|
|
103
112
|
if (!iframe)
|
|
@@ -18,6 +18,7 @@ export declare const selectorsLibrary: {
|
|
|
18
18
|
selectOptionParents: (id: number) => readonly number[];
|
|
19
19
|
selectRadioSiblings: (id: number) => Readonly<number[] | undefined>;
|
|
20
20
|
selectVariableReference: (id: number, noThrow?: any) => Readonly<import("@legalplace/models-v3-types").VariableV3>;
|
|
21
|
+
selectVariablesReference: (ids: number[], noThrow?: any) => readonly import("@legalplace/models-v3-types").VariableV3[];
|
|
21
22
|
selectVariableRelations: (id: number) => Readonly<import("@legalplace/referencesparser/dist/libs/References.type").ReferencesRelationsVariablesType>;
|
|
22
23
|
selectVariableParents: (id: number) => readonly number[];
|
|
23
24
|
selectAllDocumentsReferences: () => Readonly<import("@legalplace/referencesparser/dist/libs/References.type").ReferencesDocumentsListType>;
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import type { VariableV3 } from "@legalplace/models-v3-types";
|
|
1
2
|
export declare const selectReferences: () => Readonly<import("@legalplace/referencesparser/dist/libs/References.type").ReferencesType>;
|
|
2
3
|
export declare const selectOutputReference: (id: number) => Readonly<import("@legalplace/referencesparser/dist/libs/References.type").ReferencesSingleOutputType | undefined>;
|
|
3
4
|
export declare const selectBoxReference: (id: number) => Readonly<import("@legalplace/referencesparser/dist/libs/References.type").ReferencesSingleBoxType>;
|
|
@@ -7,7 +8,8 @@ export declare const selectOptionRelations: (id: number) => Readonly<import("@le
|
|
|
7
8
|
export declare const selectSectionRelations: (id: number) => Readonly<import("@legalplace/referencesparser/dist/libs/References.type").ReferencesRelationsSectionsType>;
|
|
8
9
|
export declare const selectOptionParents: (id: number) => readonly number[];
|
|
9
10
|
export declare const selectRadioSiblings: (id: number) => Readonly<number[] | undefined>;
|
|
10
|
-
export declare const selectVariableReference: (id: number, noThrow?: any) => Readonly<
|
|
11
|
+
export declare const selectVariableReference: (id: number, noThrow?: any) => Readonly<VariableV3>;
|
|
12
|
+
export declare const selectVariablesReference: (ids: number[], noThrow?: any) => readonly VariableV3[];
|
|
11
13
|
export declare const selectVariableRelations: (id: number) => Readonly<import("@legalplace/referencesparser/dist/libs/References.type").ReferencesRelationsVariablesType>;
|
|
12
14
|
export declare const selectVariableParents: (id: number) => readonly number[];
|
|
13
15
|
export declare const selectAllDocumentsReferences: () => Readonly<import("@legalplace/referencesparser/dist/libs/References.type").ReferencesDocumentsListType>;
|
|
@@ -47,6 +47,15 @@ export const selectVariableReference = createSelector((state, id, noThrow = fals
|
|
|
47
47
|
throw new Error(`Variable ${id} does not exist`);
|
|
48
48
|
return state.references.variables[id];
|
|
49
49
|
}, false);
|
|
50
|
+
export const selectVariablesReference = createSelector((state, ids, noThrow = false) => {
|
|
51
|
+
const variables = [];
|
|
52
|
+
ids.forEach((id) => {
|
|
53
|
+
if (state.references.variables[id] === undefined && noThrow === false)
|
|
54
|
+
throw new Error(`Variable ${id} does not exist`);
|
|
55
|
+
variables.push(state.references.variables[id]);
|
|
56
|
+
});
|
|
57
|
+
return variables;
|
|
58
|
+
}, false);
|
|
50
59
|
export const selectVariableRelations = createSelector((state, id) => {
|
|
51
60
|
if (state.references.relations.variables[id] === undefined)
|
|
52
61
|
throw new Error(`Variable ${id} relations do not exist`);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legalplace/wizardx-core",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.28.0",
|
|
4
4
|
"author": "Moncef Hammou (moncef@legalplace.fr)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -96,5 +96,5 @@
|
|
|
96
96
|
"*.test.ts",
|
|
97
97
|
"*.test.tsx"
|
|
98
98
|
],
|
|
99
|
-
"gitHead": "
|
|
99
|
+
"gitHead": "56e2c78c9e97ea5cc6d5c57ad736776087569725"
|
|
100
100
|
}
|