@legalplace/wizardx-core 4.42.10-nightly.20251125120616 → 4.42.11
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/README.md +1 -376
- package/dist/App.d.ts +6 -1
- package/dist/App.js +7 -2
- package/dist/App.test.js +37 -0
- package/dist/Loader.d.ts +1 -1
- package/dist/Loader.js +1 -1
- package/dist/PluginLoader.d.ts +36 -21
- package/dist/PluginLoader.js +227 -90
- package/dist/PluginLoader.test.d.ts +1 -0
- package/dist/PluginLoader.test.js +52 -0
- package/dist/Shimmer.d.ts +11 -8
- package/dist/Shimmer.js +4 -4
- package/dist/ThemeLoader.d.ts +8 -8
- package/dist/ThemeLoader.test.d.ts +2 -0
- package/dist/ThemeLoader.test.js +65 -0
- package/dist/components/PluginRoute.d.ts +2 -2
- package/dist/components/PluginRoute.js +4 -3
- package/dist/components/SmartScript.d.ts +6 -2
- package/dist/components/SmartScript.js +1 -1
- package/dist/components/UserLocked/UserLockedComponent.js +2 -2
- package/dist/components/View.d.ts +3 -3
- package/dist/components/View.js +7 -5
- package/dist/components/View.test.d.ts +2 -0
- package/dist/components/View.test.js +84 -0
- package/dist/componentsConnectors/connectBox.d.ts +6 -4
- package/dist/componentsConnectors/connectBox.test.d.ts +1 -0
- package/dist/componentsConnectors/connectBox.test.js +218 -0
- package/dist/componentsConnectors/connectDocument.d.ts +6 -4
- package/dist/componentsConnectors/connectDocument.test.d.ts +1 -0
- package/dist/componentsConnectors/connectDocument.test.js +95 -0
- package/dist/componentsConnectors/connectHeader.d.ts +6 -4
- package/dist/componentsConnectors/connectMetaTitle.d.ts +7 -3
- package/dist/componentsConnectors/connectMetaTitle.test.d.ts +1 -0
- package/dist/componentsConnectors/connectMetaTitle.test.js +32 -0
- package/dist/componentsConnectors/connectOption.d.ts +7 -5
- package/dist/componentsConnectors/connectPagination.d.ts +7 -5
- package/dist/componentsConnectors/connectPreview.d.ts +7 -3
- package/dist/componentsConnectors/connectProgress.d.ts +6 -4
- package/dist/componentsConnectors/connectRootOption.d.ts +7 -5
- package/dist/componentsConnectors/connectSection.d.ts +6 -4
- package/dist/componentsConnectors/connectSummary.d.ts +9 -5
- package/dist/componentsConnectors/connectSummaryItem.d.ts +6 -4
- package/dist/componentsConnectors/connectTermsheet.js +1 -1
- package/dist/componentsConnectors/connectVariable.d.ts +8 -6
- package/dist/componentsConnectors/connectWizardWrapper.d.ts +6 -4
- package/dist/componentsConnectors/connector/componentConnector.d.ts +10 -7
- package/dist/componentsConnectors/connector/componentConnector.js +3 -3
- package/dist/componentsConnectors/library.d.ts +81 -47
- package/dist/config.test.d.ts +1 -0
- package/dist/config.test.js +54 -0
- package/dist/helpers/activitiesHelper.d.ts +3 -3
- package/dist/helpers/autocomplete.helper.d.ts +2 -2
- package/dist/helpers/autocomplete.helper.js +1 -1
- package/dist/helpers/autosave.helper.d.ts +13 -3
- package/dist/helpers/autosave.helper.js +70 -3
- package/dist/helpers/inpiCitiesHelper.js +1 -1
- package/dist/helpers/outputsParsing.d.ts +9 -9
- package/dist/hooks/useDispatch.d.ts +1 -1
- package/dist/hooks/usePrevious.js +1 -1
- package/dist/index.d.ts +0 -3
- package/dist/index.js +0 -3
- package/dist/libs/ConditionsRunner.d.ts +1 -1
- package/dist/libs/Formatter/FormatAddress.d.ts +1 -1
- package/dist/libs/InputsInitiator.d.ts +1 -1
- package/dist/libs/NumAuto.test.d.ts +1 -0
- package/dist/libs/NumAuto.test.js +43 -0
- package/dist/libs/PathReader.d.ts +1 -96
- package/dist/libs/PathReader.js +2 -1
- package/dist/libs/SectionValidity.test.d.ts +1 -0
- package/dist/libs/SectionValidity.test.js +116 -0
- package/dist/libs/SmartScriptStore.d.ts +6 -6
- package/dist/redux/actions/app.d.ts +1 -1
- package/dist/redux/actions/app.test.d.ts +1 -0
- package/dist/redux/actions/app.test.js +90 -0
- package/dist/redux/actions/conditions.test.d.ts +1 -0
- package/dist/redux/actions/conditions.test.js +68 -0
- package/dist/redux/actions/inputs.d.ts +1 -1
- package/dist/redux/actions/inputs.test.d.ts +1 -0
- package/dist/redux/actions/inputs.test.js +53 -0
- package/dist/redux/actions/library.d.ts +21 -15
- package/dist/redux/actions/references.d.ts +2 -2
- package/dist/redux/actions/references.test.d.ts +1 -0
- package/dist/redux/actions/references.test.js +43 -0
- package/dist/redux/actions/sagas/data.d.ts +1 -1
- package/dist/redux/actions/sagas/data.test.d.ts +1 -0
- package/dist/redux/actions/sagas/data.test.js +11 -0
- package/dist/redux/actions/sagas/model.test.d.ts +1 -0
- package/dist/redux/actions/sagas/model.test.js +11 -0
- package/dist/redux/actions/sagas/user.d.ts +1 -1
- package/dist/redux/actions/user.test.d.ts +1 -0
- package/dist/redux/actions/user.test.js +16 -0
- package/dist/redux/listeners/subscriber.d.ts +1 -1
- package/dist/redux/listeners/subscriber.test.d.ts +1 -0
- package/dist/redux/listeners/subscriber.test.js +31 -0
- package/dist/redux/middlewares/conditionsWatcherMiddleware.d.ts +1 -1
- package/dist/redux/middlewares/conditionsWatcherMiddleware.test.d.ts +1 -0
- package/dist/redux/middlewares/conditionsWatcherMiddleware.test.js +330 -0
- package/dist/redux/middlewares/evaluationsWatcherMiddleware.d.ts +1 -1
- package/dist/redux/middlewares/evaluationsWatcherMiddleware.test.d.ts +1 -0
- package/dist/redux/middlewares/evaluationsWatcherMiddleware.test.js +242 -0
- package/dist/redux/middlewares/mandatoriesWatcherMiddleware.d.ts +1 -1
- package/dist/redux/middlewares/multiplesActionsMiddleware.d.ts +1 -1
- package/dist/redux/middlewares/multiplesActionsMiddleware.test.d.ts +1 -0
- package/dist/redux/middlewares/multiplesActionsMiddleware.test.js +209 -0
- package/dist/redux/middlewares/paginationWatcherMiddleware.d.ts +2 -2
- package/dist/redux/middlewares/pluginsHookMiddleware.d.ts +2 -1
- package/dist/redux/middlewares/pluginsHookMiddleware.js +7 -1
- package/dist/redux/middlewares/prefillerWatcherMiddleware.d.ts +1 -1
- package/dist/redux/middlewares/prefillerWatcherMiddleware.test.d.ts +1 -0
- package/dist/redux/middlewares/prefillerWatcherMiddleware.test.js +84 -0
- package/dist/redux/middlewares/smartscriptMiddleware.d.ts +1 -1
- package/dist/redux/middlewares/smartscriptMiddleware.js +2 -2
- package/dist/redux/middlewares/thirdpartyScriptsMiddleware.d.ts +1 -1
- package/dist/redux/reducers/app/instance.test.d.ts +1 -0
- package/dist/redux/reducers/app/instance.test.js +75 -0
- package/dist/redux/reducers/app/meta.test.d.ts +1 -0
- package/dist/redux/reducers/app/meta.test.js +70 -0
- package/dist/redux/reducers/app/pagination/updateAvailableAppStates.js +2 -1
- package/dist/redux/reducers/app/pagination.test.d.ts +1 -0
- package/dist/redux/reducers/app/pagination.test.js +134 -0
- package/dist/redux/reducers/app/wizard.test.d.ts +1 -0
- package/dist/redux/reducers/app/wizard.test.js +53 -0
- package/dist/redux/reducers/app.d.ts +6 -6
- package/dist/redux/reducers/app.test.d.ts +1 -0
- package/dist/redux/reducers/app.test.js +175 -0
- package/dist/redux/reducers/conditions/addMultipleOccurency.test.d.ts +1 -0
- package/dist/redux/reducers/conditions/addMultipleOccurency.test.js +108 -0
- package/dist/redux/reducers/conditions/deleteMultipleOccurency.test.d.ts +1 -0
- package/dist/redux/reducers/conditions/deleteMultipleOccurency.test.js +77 -0
- package/dist/redux/reducers/conditions/updateDocumentConditions.test.d.ts +1 -0
- package/dist/redux/reducers/conditions/updateDocumentConditions.test.js +35 -0
- package/dist/redux/reducers/conditions/updateOptionValidatorCondition.test.d.ts +1 -0
- package/dist/redux/reducers/conditions/updateOptionValidatorCondition.test.js +35 -0
- package/dist/redux/reducers/conditions/updateVariableValidatorCondition.test.d.ts +1 -0
- package/dist/redux/reducers/conditions/updateVariableValidatorCondition.test.js +35 -0
- package/dist/redux/reducers/conditions.test.d.ts +1 -0
- package/dist/redux/reducers/conditions.test.js +196 -0
- package/dist/redux/reducers/inputs/addMultipleOccurency.test.d.ts +1 -0
- package/dist/redux/reducers/inputs/addMultipleOccurency.test.js +101 -0
- package/dist/redux/reducers/inputs/deleteMultipleOccurency.test.d.ts +1 -0
- package/dist/redux/reducers/inputs/deleteMultipleOccurency.test.js +56 -0
- package/dist/redux/reducers/inputs.test.d.ts +1 -0
- package/dist/redux/reducers/inputs.test.js +171 -0
- package/dist/redux/reducers/references.js +0 -2
- package/dist/redux/reducers/user.test.d.ts +1 -0
- package/dist/redux/reducers/user.test.js +42 -0
- package/dist/redux/routerHistore.test.d.ts +1 -0
- package/dist/redux/routerHistore.test.js +15 -0
- package/dist/redux/sagas/fetchModel.test.d.ts +1 -0
- package/dist/redux/sagas/fetchModel.test.js +127 -0
- package/dist/redux/sagas/runner.test.d.ts +1 -0
- package/dist/redux/sagas/runner.test.js +10 -0
- package/dist/redux/sagas/saveData.test.d.ts +1 -0
- package/dist/redux/sagas/saveData.test.js +74 -0
- package/dist/redux/sagas/setDefaults.test.d.ts +1 -0
- package/dist/redux/sagas/setDefaults.test.js +73 -0
- package/dist/redux/selectors/app.test.d.ts +1 -0
- package/dist/redux/selectors/app.test.js +99 -0
- package/dist/redux/selectors/conditions.test.d.ts +1 -0
- package/dist/redux/selectors/conditions.test.js +70 -0
- package/dist/redux/selectors/inputs.d.ts +1 -1
- package/dist/redux/selectors/inputs.test.d.ts +1 -0
- package/dist/redux/selectors/inputs.test.js +44 -0
- package/dist/redux/selectors/references.test.d.ts +1 -0
- package/dist/redux/selectors/references.test.js +471 -0
- package/dist/redux/selectors/selectors.d.ts +4 -4
- package/dist/redux/selectors/selectors.test.d.ts +1 -0
- package/dist/redux/selectors/selectors.test.js +16 -0
- package/dist/redux/selectors/user.test.d.ts +1 -0
- package/dist/redux/selectors/user.test.js +29 -0
- package/dist/redux/store.d.ts +3 -5
- package/dist/redux/store.js +1 -2
- package/dist/redux/store.test.d.ts +1 -0
- package/dist/redux/store.test.js +16 -0
- package/dist/service/api.manager.d.ts +2 -2
- package/dist/service/autocomplete.manager.d.ts +3 -3
- package/dist/service/autocomplete.manager.js +3 -3
- package/dist/tests-misc/plugins/jestTestPlugin/after.js +1 -1
- package/dist/tests-misc/plugins/jestTestPlugin/before.js +1 -1
- package/dist/tests-misc/plugins/jestTestPlugin/title.js +1 -1
- package/dist/tests-misc/themes/jestTestTheme/components/EmailComponent.d.ts +1 -1
- package/dist/tests-misc/themes/jestTestTheme/components/EmailComponent.js +1 -1
- package/dist/tests-misc/themes/jestTestTheme/components/TermsheetComponent.d.ts +1 -1
- package/dist/tests-misc/themes/jestTestTheme/components/TermsheetComponent.js +1 -1
- package/dist/tests-misc/themes/jestTestTheme/components/WizardComponent.d.ts +1 -1
- package/dist/tests-misc/themes/jestTestTheme/components/WizardComponent.js +1 -1
- package/dist/types/Actions.type.d.ts +6 -70
- package/dist/types/Components.type.d.ts +2 -3
- package/dist/types/PluginConfig.type.d.ts +52 -18
- package/dist/types/State.type.d.ts +2 -2
- package/dist/types/config.type.d.ts +1 -1
- package/dist/types/getActions.type.d.ts +1 -1
- package/dist/types/getConnectors.type.d.ts +2 -2
- package/dist/types/getSelectors.type.d.ts +1 -1
- package/package.json +22 -45
- package/dist/WizardCore.d.ts +0 -29
- package/dist/WizardCore.js +0 -153
- package/dist/app.entry.d.ts +0 -2
- package/dist/app.entry.js +0 -1
- package/dist/routing/adapters/nextjs.adapter.d.ts +0 -3
- package/dist/routing/adapters/nextjs.adapter.js +0 -61
- package/dist/routing/adapters/reactRouter.adapter.d.ts +0 -2
- package/dist/routing/adapters/reactRouter.adapter.js +0 -16
- package/dist/routing/context.d.ts +0 -14
- package/dist/routing/context.js +0 -23
- package/dist/routing/index.d.ts +0 -4
- package/dist/routing/index.js +0 -4
- package/dist/routing/types.d.ts +0 -26
- package/dist/wizardcore.entry.d.ts +0 -3
- package/dist/wizardcore.entry.js +0 -2
- /package/dist/{routing/types.js → App.test.d.ts} +0 -0
package/dist/PluginLoader.js
CHANGED
|
@@ -1,116 +1,253 @@
|
|
|
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 { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
11
|
import React from "react";
|
|
12
|
+
import PropTypes from "prop-types";
|
|
13
|
+
import { getConfig } from "./config";
|
|
3
14
|
import { getStore } from "./redux/store";
|
|
15
|
+
import { getHistory } from "./redux/routerHistory";
|
|
16
|
+
import Globals from "./Globals";
|
|
17
|
+
import { INIT_PLUGINS } from "./redux/constants/app";
|
|
18
|
+
let globalAnchors = {};
|
|
19
|
+
let reduxAnchors = {};
|
|
20
|
+
let actionOverrideAnchor = {};
|
|
21
|
+
let replacers = {};
|
|
4
22
|
let pluginsStoreReducers = {};
|
|
5
|
-
|
|
6
|
-
const
|
|
23
|
+
const pluginsStoreSagas = {};
|
|
24
|
+
export const getPluginsStoreReducers = () => pluginsStoreReducers;
|
|
25
|
+
export const getPluginsStoreSagas = () => pluginsStoreSagas;
|
|
26
|
+
let PluginsAppStatesRegistrers = [];
|
|
27
|
+
let PluginsPageAppStates = {};
|
|
28
|
+
let PluginsAppStatesComponents = {};
|
|
29
|
+
let PluginAdditionRoutes = {};
|
|
30
|
+
const pluginAppStates = (declaration) => {
|
|
31
|
+
PluginsAppStatesRegistrers.push(declaration.register);
|
|
32
|
+
if (typeof declaration.pageAppState === "object")
|
|
33
|
+
Object.keys(declaration.pageAppState).forEach((appState) => {
|
|
34
|
+
if (typeof declaration.pageAppState[appState] === "string") {
|
|
35
|
+
const page = declaration.pageAppState[appState];
|
|
36
|
+
if (Object.prototype.hasOwnProperty.call(PluginsPageAppStates, appState)) {
|
|
37
|
+
throw new Error(`Plugins AppState "${appState}" already declared.`);
|
|
38
|
+
}
|
|
39
|
+
const samePageAppStates = Object.keys(PluginsPageAppStates).filter((currentAppState) => PluginsPageAppStates[currentAppState] === page);
|
|
40
|
+
if (samePageAppStates.length > 0)
|
|
41
|
+
throw new Error(`Plugins AppState page "${page}" already declared.`);
|
|
42
|
+
PluginsPageAppStates[appState] = page;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
Object.keys(declaration.components).forEach((appState) => {
|
|
46
|
+
if (Object.prototype.hasOwnProperty.call(declaration, appState) === true)
|
|
47
|
+
throw new Error(`Plugin's appState ${appState} already declared previously`);
|
|
48
|
+
PluginsAppStatesComponents[appState] = declaration.components[appState];
|
|
49
|
+
});
|
|
50
|
+
};
|
|
51
|
+
export const registerPluginsAppStates = (currentAppStates) => {
|
|
52
|
+
let appStates = [...currentAppStates];
|
|
53
|
+
PluginsAppStatesRegistrers.forEach((register) => {
|
|
54
|
+
appStates = register(appStates);
|
|
55
|
+
});
|
|
56
|
+
return appStates;
|
|
57
|
+
};
|
|
58
|
+
export const loadPluginComponent = (name) => {
|
|
59
|
+
if (Object.prototype.hasOwnProperty.call(PluginsAppStatesComponents, name) ===
|
|
60
|
+
false) {
|
|
61
|
+
return undefined;
|
|
62
|
+
}
|
|
63
|
+
return PluginsAppStatesComponents[name];
|
|
64
|
+
};
|
|
65
|
+
export const pluginPageAppState = (page) => {
|
|
66
|
+
const appStates = Object.keys(PluginsPageAppStates).filter((appState) => PluginsPageAppStates[appState] === page);
|
|
67
|
+
if (appStates.length === 1)
|
|
68
|
+
return appStates[0];
|
|
69
|
+
if (appStates.length > 1)
|
|
70
|
+
throw new Error("Found multipled appStates when checking for plugins page name");
|
|
71
|
+
return false;
|
|
72
|
+
};
|
|
73
|
+
export const getPluginsPageAppStates = () => PluginsPageAppStates;
|
|
74
|
+
const loadPluginFiles = (pluginsList) => __awaiter(void 0, void 0, void 0, function* () {
|
|
75
|
+
const plugins = Object.keys(pluginsList);
|
|
76
|
+
const pluginModules = yield Promise.all(plugins.map((plugin) => Globals.loadPlugin(plugin)));
|
|
77
|
+
plugins.forEach((plugin, index) => {
|
|
78
|
+
const pluginModule = pluginModules[index];
|
|
79
|
+
const anchors = pluginModule.default;
|
|
80
|
+
const { loader } = pluginModule;
|
|
81
|
+
if (loader !== undefined) {
|
|
82
|
+
loader(getStore().dispatch, getHistory(), getConfig());
|
|
83
|
+
}
|
|
84
|
+
Object.keys(anchors).forEach((anchor) => {
|
|
85
|
+
if (anchor === "replace") {
|
|
86
|
+
Object.keys(anchors[anchor]).forEach((replacer) => {
|
|
87
|
+
if (!Object.prototype.hasOwnProperty.call(replacers, replacer)) {
|
|
88
|
+
replacers[replacer] = [];
|
|
89
|
+
}
|
|
90
|
+
replacers[replacer].push(anchors[anchor][replacer]);
|
|
91
|
+
});
|
|
92
|
+
return;
|
|
93
|
+
}
|
|
94
|
+
if (anchor === "appstates") {
|
|
95
|
+
pluginAppStates(anchors.appstates);
|
|
96
|
+
}
|
|
97
|
+
if (anchor === "redux") {
|
|
98
|
+
Object.keys(anchors[anchor]).forEach((action) => {
|
|
99
|
+
if (reduxAnchors[action] === undefined)
|
|
100
|
+
reduxAnchors[action] = [];
|
|
101
|
+
reduxAnchors[action].push(anchors[anchor][action]);
|
|
102
|
+
});
|
|
103
|
+
return;
|
|
104
|
+
}
|
|
105
|
+
if (anchor === "actionOverride") {
|
|
106
|
+
Object.keys(anchors[anchor]).forEach((action) => {
|
|
107
|
+
if (actionOverrideAnchor[action] === undefined)
|
|
108
|
+
actionOverrideAnchor[action] = [];
|
|
109
|
+
actionOverrideAnchor[action].push(anchors[anchor][action]);
|
|
110
|
+
});
|
|
111
|
+
return;
|
|
112
|
+
}
|
|
113
|
+
if (anchor === "additionalRoutes") {
|
|
114
|
+
Object.keys(anchors[anchor]).forEach((route) => {
|
|
115
|
+
PluginAdditionRoutes[anchors[anchor][route].path] =
|
|
116
|
+
anchors[anchor][route].component;
|
|
117
|
+
});
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
if (anchor === "reduxStore" && anchors[anchor].reducer) {
|
|
121
|
+
pluginsStoreReducers[plugin] = anchors[anchor].reducer;
|
|
122
|
+
}
|
|
123
|
+
if (anchor === "reduxStore" && anchors[anchor].sagas) {
|
|
124
|
+
pluginsStoreSagas[plugin] = anchors[anchor].sagas;
|
|
125
|
+
}
|
|
126
|
+
if (!Object.prototype.hasOwnProperty.call(globalAnchors, anchor))
|
|
127
|
+
globalAnchors[anchor] = [];
|
|
128
|
+
globalAnchors[anchor].push(anchors[anchor]);
|
|
129
|
+
});
|
|
130
|
+
if (typeof anchors.onLoad === "function")
|
|
131
|
+
anchors.onLoad();
|
|
132
|
+
});
|
|
133
|
+
if (Object.keys(pluginsStoreReducers).length > 0 ||
|
|
134
|
+
Object.keys(pluginsStoreSagas).length > 0) {
|
|
135
|
+
getStore().dispatch({ type: INIT_PLUGINS });
|
|
136
|
+
}
|
|
137
|
+
});
|
|
138
|
+
let pluginsLoadingDone = false;
|
|
139
|
+
export const loadPlugins = (plugins) => __awaiter(void 0, void 0, void 0, function* () {
|
|
140
|
+
let pluginsList;
|
|
141
|
+
if (!plugins)
|
|
142
|
+
pluginsList = getConfig().plugins;
|
|
143
|
+
else
|
|
144
|
+
pluginsList = plugins;
|
|
145
|
+
if (pluginsList === undefined) {
|
|
146
|
+
pluginsList = getConfig().plugins;
|
|
147
|
+
}
|
|
148
|
+
yield loadPluginFiles(pluginsList);
|
|
149
|
+
pluginsLoadingDone = true;
|
|
150
|
+
});
|
|
151
|
+
export const pluginsLoaded = () => pluginsLoadingDone;
|
|
7
152
|
export const PluginLoader = (props) => {
|
|
8
153
|
const { anchor } = props;
|
|
9
|
-
const
|
|
154
|
+
const anchorsList = !Array.isArray(anchor) ? [anchor] : anchor;
|
|
10
155
|
let Plugins = [];
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
156
|
+
for (let i = 0; i < anchorsList.length; i += 1) {
|
|
157
|
+
const currentAnchor = anchorsList[i];
|
|
158
|
+
if (Object.prototype.hasOwnProperty.call(globalAnchors, currentAnchor) &&
|
|
159
|
+
globalAnchors[currentAnchor].length > 0) {
|
|
160
|
+
const currentPlugins = globalAnchors[currentAnchor];
|
|
161
|
+
Plugins = [
|
|
162
|
+
...Plugins,
|
|
163
|
+
...currentPlugins.map((Plugin) => (_jsx(React.Suspense, Object.assign({ fallback: null }, { children: _jsx(Plugin, Object.assign({}, props.props), void 0) }), `lpwp-${currentAnchor}-${Math.random()}`))),
|
|
164
|
+
];
|
|
17
165
|
}
|
|
18
|
-
return true;
|
|
19
|
-
});
|
|
20
|
-
if (matchedPlugins.length > 0) {
|
|
21
|
-
Plugins = matchedPlugins.map((p, i) => (_jsx(p.component, Object.assign({}, (props.props || {})), i)));
|
|
22
166
|
}
|
|
23
|
-
|
|
167
|
+
if (Plugins.length > 0) {
|
|
168
|
+
return _jsx(_Fragment, { children: Plugins }, void 0);
|
|
169
|
+
}
|
|
170
|
+
return null;
|
|
171
|
+
};
|
|
172
|
+
PluginLoader.propTypes = {
|
|
173
|
+
anchor: PropTypes.arrayOf(PropTypes.string.isRequired).isRequired,
|
|
174
|
+
props: PropTypes.object,
|
|
24
175
|
};
|
|
176
|
+
PluginLoader.defaultProps = {
|
|
177
|
+
props: {},
|
|
178
|
+
};
|
|
179
|
+
let cache = {};
|
|
25
180
|
export function replaceComponent(replacerName, OriginalComponent, componentName) {
|
|
181
|
+
const displayName = componentName ||
|
|
182
|
+
OriginalComponent.displayName ||
|
|
183
|
+
OriginalComponent.name ||
|
|
184
|
+
"Component";
|
|
185
|
+
const anchorsList = !Array.isArray(replacerName)
|
|
186
|
+
? [replacerName]
|
|
187
|
+
: replacerName;
|
|
26
188
|
let Replacer = null;
|
|
27
|
-
const
|
|
28
|
-
if (
|
|
29
|
-
|
|
30
|
-
if (replacers[r])
|
|
31
|
-
Replacer = r;
|
|
32
|
-
});
|
|
189
|
+
const cacheKey = anchorsList.reduce((a, b) => a + b) + OriginalComponent.toString();
|
|
190
|
+
if (Object.prototype.hasOwnProperty.call(cache, cacheKey)) {
|
|
191
|
+
return cache[cacheKey];
|
|
33
192
|
}
|
|
34
|
-
|
|
35
|
-
|
|
193
|
+
for (let i = 0; i < anchorsList.length; i += 1) {
|
|
194
|
+
const currentAnchor = anchorsList[i];
|
|
195
|
+
if (Object.prototype.hasOwnProperty.call(replacers, currentAnchor)) {
|
|
196
|
+
Replacer = currentAnchor;
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
36
199
|
}
|
|
200
|
+
let FinalComponent;
|
|
37
201
|
if (Replacer !== null) {
|
|
38
|
-
const BaseComponent = (props) => (_jsx(OriginalComponent, Object.assign({}, props, { children: props.children })));
|
|
202
|
+
const BaseComponent = (props) => (_jsx(OriginalComponent, Object.assign({}, props, { children: props.children }), void 0));
|
|
39
203
|
const FinalReplacedComponent = replacers[Replacer].reduce((PreviousReplacer, CurrentReplacer) => {
|
|
40
|
-
const ReplacedComponent = (props) => (_jsx(React.Suspense, { fallback: null, children: _jsx(CurrentReplacer, Object.assign({}, props, { OriginalComponent: PreviousReplacer, children: props.children })) }));
|
|
204
|
+
const ReplacedComponent = (props) => (_jsx(React.Suspense, Object.assign({ fallback: null }, { children: _jsx(CurrentReplacer, Object.assign({}, props, { OriginalComponent: PreviousReplacer }, { children: props.children }), void 0) }), void 0));
|
|
41
205
|
return ReplacedComponent;
|
|
42
206
|
}, BaseComponent);
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
return FinalReplacedComponent;
|
|
207
|
+
FinalComponent = FinalReplacedComponent;
|
|
208
|
+
FinalComponent.displayName = `replacedComponent(${displayName})`;
|
|
47
209
|
}
|
|
48
|
-
|
|
210
|
+
else {
|
|
211
|
+
FinalComponent = OriginalComponent;
|
|
212
|
+
FinalComponent.displayName = `originalComponent(${displayName})`;
|
|
213
|
+
}
|
|
214
|
+
cache[cacheKey] = React.memo(FinalComponent);
|
|
215
|
+
return cache[cacheKey];
|
|
49
216
|
}
|
|
50
217
|
export const ReplaceFragment = ({ replacerName, fragmentName, children, }) => {
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
218
|
+
const Fragment = () => _jsx(_Fragment, { children: children }, void 0);
|
|
219
|
+
const FinalFragment = replaceComponent(replacerName, Fragment, `Fragment::${fragmentName}`);
|
|
220
|
+
return _jsx(FinalFragment, {}, void 0);
|
|
221
|
+
};
|
|
222
|
+
export function RunActionAnchor(anchor, ...args) {
|
|
223
|
+
if (Object.prototype.hasOwnProperty.call(reduxAnchors, anchor) &&
|
|
224
|
+
reduxAnchors[anchor].length > 0) {
|
|
225
|
+
reduxAnchors[anchor].forEach((currentFn) => {
|
|
226
|
+
currentFn.call(null, ...args);
|
|
56
227
|
});
|
|
57
228
|
}
|
|
58
|
-
else if (replacers[replacerName]) {
|
|
59
|
-
Replacer = replacerName;
|
|
60
|
-
}
|
|
61
|
-
if (Replacer !== null) {
|
|
62
|
-
const Fragment = (props) => _jsx(_Fragment, { children: props.children });
|
|
63
|
-
const FinalReplacedComponent = replacers[Replacer].reduce((PreviousReplacer, CurrentReplacer) => {
|
|
64
|
-
const ReplacedComponent = (props) => (_jsx(React.Suspense, { fallback: null, children: _jsx(CurrentReplacer, Object.assign({}, props, { OriginalComponent: PreviousReplacer, children: props.children })) }));
|
|
65
|
-
return ReplacedComponent;
|
|
66
|
-
}, Fragment);
|
|
67
|
-
if (fragmentName) {
|
|
68
|
-
FinalReplacedComponent.displayName = `Replaced(${fragmentName})`;
|
|
69
|
-
}
|
|
70
|
-
return _jsx(FinalReplacedComponent, { children: children });
|
|
71
|
-
}
|
|
72
|
-
return _jsx(_Fragment, { children: children });
|
|
73
|
-
};
|
|
74
|
-
export function registerReplacer(replacerName, Replacer) {
|
|
75
|
-
if (!replacers[replacerName])
|
|
76
|
-
replacers[replacerName] = [];
|
|
77
|
-
replacers[replacerName].push(Replacer);
|
|
78
|
-
}
|
|
79
|
-
export function loadPlugins(plugins) {
|
|
80
|
-
const promises = [];
|
|
81
|
-
const store = getStore();
|
|
82
|
-
Object.keys(plugins).forEach((key) => {
|
|
83
|
-
promises.push(plugins[key]().then((plugin) => {
|
|
84
|
-
if (plugin.redux) {
|
|
85
|
-
pluginsStoreReducers = Object.assign(Object.assign({}, pluginsStoreReducers), { [key]: plugin.redux.reducer });
|
|
86
|
-
pluginsSagas = [...pluginsSagas, ...plugin.redux.sagas];
|
|
87
|
-
}
|
|
88
|
-
}));
|
|
89
|
-
});
|
|
90
|
-
return Promise.all(promises);
|
|
91
|
-
}
|
|
92
|
-
export function getPluginsReducers() {
|
|
93
|
-
return pluginsStoreReducers;
|
|
94
|
-
}
|
|
95
|
-
export function getPluginsAdditionalRoutes() {
|
|
96
|
-
const routes = [];
|
|
97
|
-
const plugins = getStore().getState().pluginsStore;
|
|
98
|
-
plugins.config.forEach((p) => {
|
|
99
|
-
if (p.anchor[0] === "routes") {
|
|
100
|
-
routes.push(p);
|
|
101
|
-
}
|
|
102
|
-
});
|
|
103
|
-
return routes;
|
|
104
229
|
}
|
|
105
|
-
export function
|
|
106
|
-
|
|
230
|
+
export function RunOverrideActionAnchor(action) {
|
|
231
|
+
let overridedAction = action;
|
|
232
|
+
if (Object.prototype.hasOwnProperty.call(actionOverrideAnchor, action.type) &&
|
|
233
|
+
actionOverrideAnchor[action.type].length > 0) {
|
|
234
|
+
actionOverrideAnchor[action.type].forEach((currentFn) => {
|
|
235
|
+
overridedAction = currentFn.call(null, overridedAction);
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
return overridedAction;
|
|
107
239
|
}
|
|
108
|
-
export
|
|
240
|
+
export const getPluginsAdditionalRoutes = () => PluginAdditionRoutes;
|
|
241
|
+
export const clearPlugins = () => {
|
|
242
|
+
globalAnchors = {};
|
|
243
|
+
reduxAnchors = {};
|
|
244
|
+
actionOverrideAnchor = {};
|
|
245
|
+
replacers = {};
|
|
246
|
+
PluginsAppStatesRegistrers = [];
|
|
247
|
+
PluginsPageAppStates = {};
|
|
248
|
+
PluginsAppStatesComponents = {};
|
|
249
|
+
PluginAdditionRoutes = {};
|
|
250
|
+
cache = {};
|
|
251
|
+
pluginsLoadingDone = false;
|
|
109
252
|
pluginsStoreReducers = {};
|
|
110
|
-
|
|
111
|
-
}
|
|
112
|
-
export const RunActionAnchor = () => { };
|
|
113
|
-
export const RunOverrideActionAnchor = () => { };
|
|
114
|
-
export const registerPluginsAppStates = () => { };
|
|
115
|
-
export const getPluginsStoreReducers = getPluginsReducers;
|
|
116
|
-
export const getPluginsStoreSagas = getPluginsSagas;
|
|
253
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
@@ -0,0 +1,52 @@
|
|
|
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
|
+
};
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
12
|
+
import { render, waitFor } from '@testing-library/react';
|
|
13
|
+
import { replaceComponent } from './PluginLoader';
|
|
14
|
+
jest.mock('react', () => {
|
|
15
|
+
const rct = jest.requireActual('react');
|
|
16
|
+
const Loadable = jest.requireActual('@loadable/component');
|
|
17
|
+
rct.lazy = Loadable.lazy;
|
|
18
|
+
return rct;
|
|
19
|
+
});
|
|
20
|
+
jest.mock('./config', () => ({
|
|
21
|
+
getConfig: () => ({
|
|
22
|
+
plugins: {
|
|
23
|
+
jestTestPlugin: '1.0.0',
|
|
24
|
+
},
|
|
25
|
+
}),
|
|
26
|
+
}));
|
|
27
|
+
jest.mock('./Globals', () => ({
|
|
28
|
+
loadPlugin: (plugin) => import(`./tests-misc/plugins/${plugin}`),
|
|
29
|
+
}));
|
|
30
|
+
const { loadPlugins, PluginLoader } = require('./PluginLoader');
|
|
31
|
+
loadPlugins();
|
|
32
|
+
describe('<PluginLoader />', () => {
|
|
33
|
+
it('Loads "after" hook', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
34
|
+
const { container } = render(_jsx(PluginLoader, { anchor: ['after'] }, void 0));
|
|
35
|
+
yield waitFor(() => expect(container).toContainHTML('<div><div class="title">Hello world - AFTER</div></div>'));
|
|
36
|
+
}));
|
|
37
|
+
it('Loads "before" hook', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
38
|
+
const { container } = render(_jsx(PluginLoader, { anchor: ['before'] }, void 0));
|
|
39
|
+
yield waitFor(() => expect(container).toContainHTML('<div><h1>Hello<b>world</b>!!!</h1></div>'));
|
|
40
|
+
}));
|
|
41
|
+
it('Tries to load non existing plugin', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
+
const { container } = render(_jsx(PluginLoader, { anchor: ['myNonExistingPlugin'] }, void 0));
|
|
43
|
+
yield waitFor(() => expect(container).toContainHTML('<div></div>'));
|
|
44
|
+
}));
|
|
45
|
+
it('Loads replacement module', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
46
|
+
const Component = replaceComponent('TitleComponent', () => {
|
|
47
|
+
return _jsx("span", { children: "Original" }, void 0);
|
|
48
|
+
});
|
|
49
|
+
const { container } = render(_jsx(Component, { children: "Replaced" }, void 0));
|
|
50
|
+
yield waitFor(() => expect(container).toContainHTML('<div><h1 style="color: red;">Replaced</h1></div>'));
|
|
51
|
+
}));
|
|
52
|
+
});
|
package/dist/Shimmer.d.ts
CHANGED
|
@@ -1,12 +1,15 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import type { StateType } from "./types/State.type";
|
|
3
2
|
declare const _default: import("react-redux").ConnectedComponent<React.FC<{
|
|
4
|
-
fetchStatus:
|
|
5
|
-
|
|
6
|
-
|
|
3
|
+
fetchStatus: "failed" | "waiting" | "succeeded" | "unhealthy" | "userLocked" | "nonBlocking";
|
|
4
|
+
report: {
|
|
5
|
+
object: import("@legalplace/model-healthcheck/dist/libs/HealthCheck.type").HealthCheckReport;
|
|
6
|
+
raw: string;
|
|
7
|
+
} | undefined;
|
|
7
8
|
}>, import("react-redux").Omit<{
|
|
8
|
-
fetchStatus:
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
fetchStatus: "failed" | "waiting" | "succeeded" | "unhealthy" | "userLocked" | "nonBlocking";
|
|
10
|
+
report: {
|
|
11
|
+
object: import("@legalplace/model-healthcheck/dist/libs/HealthCheck.type").HealthCheckReport;
|
|
12
|
+
raw: string;
|
|
13
|
+
} | undefined;
|
|
14
|
+
}, "fetchStatus" | "report">>;
|
|
12
15
|
export default _default;
|
package/dist/Shimmer.js
CHANGED
|
@@ -9,7 +9,7 @@ const Shimmer = (props) => {
|
|
|
9
9
|
const [themeLoaded, setThemeloaded] = useState(false);
|
|
10
10
|
if (props.fetchStatus === "succeeded" ||
|
|
11
11
|
props.fetchStatus === "nonBlocking") {
|
|
12
|
-
return _jsx(_Fragment, { children: props.children });
|
|
12
|
+
return _jsx(_Fragment, { children: props.children }, void 0);
|
|
13
13
|
}
|
|
14
14
|
addOnThemeLoadCallback(() => {
|
|
15
15
|
if (!themeLoaded)
|
|
@@ -48,10 +48,10 @@ const Shimmer = (props) => {
|
|
|
48
48
|
borderRadius: "4px",
|
|
49
49
|
};
|
|
50
50
|
if (ThemeShimmer !== null && props.fetchStatus === "waiting") {
|
|
51
|
-
return _jsx(ThemeShimmer, {});
|
|
51
|
+
return _jsx(ThemeShimmer, {}, void 0);
|
|
52
52
|
}
|
|
53
|
-
return (_jsxs(_Fragment, { children: [["waiting", "failed"].includes(props.fetchStatus) && (_jsxs("div", { style: style, children: [props.fetchStatus === "waiting" && (_jsxs("div", { className: "lds-ripple", children: [_jsx("div", {}), _jsx("div", {})] })), props.fetchStatus === "failed" &&
|
|
54
|
-
"Une erreur a eu lieu pendant le chargement du questionnaire"] })), props.fetchStatus === "userLocked" && (_jsxs(_Fragment, { children: [_jsx(PluginLoader, { anchor: ["userLockedScreen"], props: props }), _jsx(UserLockedComponent, { unhealthyStyle: unhealthyStyle })] })), props.fetchStatus === "unhealthy" && (_jsxs("div", { style: unhealthyStyle, children: ["Le mod\u00E8le semble contenir des erreurs", _jsx("pre", { style: unhealthyStylePre, children: (_a = props.report) === null || _a === void 0 ? void 0 : _a.raw })] }))] }));
|
|
53
|
+
return (_jsxs(_Fragment, { children: [["waiting", "failed"].includes(props.fetchStatus) && (_jsxs("div", Object.assign({ style: style }, { children: [props.fetchStatus === "waiting" && (_jsxs("div", Object.assign({ className: "lds-ripple" }, { children: [_jsx("div", {}, void 0), _jsx("div", {}, void 0)] }), void 0)), props.fetchStatus === "failed" &&
|
|
54
|
+
"Une erreur a eu lieu pendant le chargement du questionnaire"] }), void 0)), props.fetchStatus === "userLocked" && (_jsxs(_Fragment, { children: [_jsx(PluginLoader, { anchor: ["userLockedScreen"], props: props }, void 0), _jsx(UserLockedComponent, { unhealthyStyle: unhealthyStyle }, void 0)] }, void 0)), props.fetchStatus === "unhealthy" && (_jsxs("div", Object.assign({ style: unhealthyStyle }, { children: ["Le mod\u00E8le semble contenir des erreurs", _jsx("pre", Object.assign({ style: unhealthyStylePre }, { children: (_a = props.report) === null || _a === void 0 ? void 0 : _a.raw }), void 0)] }), void 0))] }, void 0));
|
|
55
55
|
};
|
|
56
56
|
const mapStateToProps = (state) => ({
|
|
57
57
|
fetchStatus: state.app.meta.fetchStatus === "succeeded"
|
package/dist/ThemeLoader.d.ts
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
import type React from "react";
|
|
2
2
|
import type { IWizardParamsTheme } from "./types/config.type";
|
|
3
|
-
export declare const loadTheme: (theme?: string, force?: boolean) => Promise<void>;
|
|
3
|
+
export declare const loadTheme: (theme?: string | undefined, force?: boolean | undefined) => Promise<void>;
|
|
4
4
|
export declare const getThemeShimmer: () => React.LazyExoticComponent<React.FC<{}>> | null;
|
|
5
5
|
export declare const setWizardTheme: (theme: IWizardParamsTheme) => Promise<void>;
|
|
6
6
|
export declare const getThemeParams: () => {
|
|
7
7
|
[key: string]: any;
|
|
8
8
|
ui?: {
|
|
9
|
+
[key: string]: any;
|
|
9
10
|
topbar: {
|
|
10
|
-
previewBtn: boolean;
|
|
11
11
|
[key: string]: any;
|
|
12
|
+
previewBtn: boolean;
|
|
12
13
|
};
|
|
13
|
-
|
|
14
|
-
};
|
|
14
|
+
} | undefined;
|
|
15
15
|
sidebar?: {
|
|
16
|
+
[key: string]: any;
|
|
16
17
|
default: import("./types/config.type").SideBarType;
|
|
17
18
|
states: {
|
|
19
|
+
[key: string]: import("./types/config.type").SideBarType;
|
|
18
20
|
wizard?: import("./types/config.type").SideBarType;
|
|
19
21
|
email?: import("./types/config.type").SideBarType;
|
|
20
|
-
[key: string]: import("./types/config.type").SideBarType;
|
|
21
22
|
};
|
|
22
|
-
|
|
23
|
-
};
|
|
23
|
+
} | undefined;
|
|
24
24
|
fonts?: any;
|
|
25
|
-
style?: Record<string, any
|
|
25
|
+
style?: Record<string, any> | undefined;
|
|
26
26
|
};
|
|
27
27
|
export declare const loadThemeComponent: (name: string) => React.LazyExoticComponent<React.FC<{}>>;
|
|
28
28
|
export declare const addOnThemeLoadCallback: (cb: () => void) => void;
|
|
@@ -0,0 +1,65 @@
|
|
|
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
|
+
};
|
|
10
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
11
|
+
import 'regenerator-runtime/runtime';
|
|
12
|
+
import '@testing-library/jest-dom/extend-expect';
|
|
13
|
+
import { render, cleanup, waitFor } from '@testing-library/react';
|
|
14
|
+
afterEach(cleanup);
|
|
15
|
+
jest.mock('./config', () => ({
|
|
16
|
+
__esModule: true,
|
|
17
|
+
getConfig: () => ({
|
|
18
|
+
theme: { name: 'jestTestTheme' },
|
|
19
|
+
plugins: {},
|
|
20
|
+
}),
|
|
21
|
+
loadConfig: () => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
+
return ({
|
|
23
|
+
theme: { name: 'jestTestTheme' },
|
|
24
|
+
plugins: {},
|
|
25
|
+
});
|
|
26
|
+
}),
|
|
27
|
+
isConfigReady: () => true,
|
|
28
|
+
}));
|
|
29
|
+
jest.mock('./Globals', () => ({
|
|
30
|
+
loadTheme: (theme) => import(`./tests-misc/themes/${theme}`),
|
|
31
|
+
}));
|
|
32
|
+
let loadThemeComponent;
|
|
33
|
+
let loadTheme;
|
|
34
|
+
describe('<ThemeLoader />', () => {
|
|
35
|
+
beforeEach(() => {
|
|
36
|
+
loadThemeComponent = require('./ThemeLoader').loadThemeComponent;
|
|
37
|
+
loadTheme = require('./ThemeLoader').loadTheme;
|
|
38
|
+
jest.spyOn(console, 'error').mockImplementation(() => { });
|
|
39
|
+
});
|
|
40
|
+
it('Loads WizardComponent properly', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
41
|
+
yield loadTheme();
|
|
42
|
+
const WizardComponent = loadThemeComponent('WizardComponent');
|
|
43
|
+
const { container } = render(_jsx(WizardComponent, {}, void 0));
|
|
44
|
+
yield waitFor(() => expect(container).toContainHTML('<div><h1>Wizard test theme, WizardComponent</h1></div>'));
|
|
45
|
+
}));
|
|
46
|
+
it('Loads TermsheetComponent properly', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
47
|
+
const TermsheetComponent = loadThemeComponent('TermsheetComponent');
|
|
48
|
+
const { container } = render(_jsx(TermsheetComponent, {}, void 0));
|
|
49
|
+
yield waitFor(() => expect(container).toContainHTML('<div><h1>Wizard test theme, TermsheetComponent</h1></div>'));
|
|
50
|
+
}));
|
|
51
|
+
});
|
|
52
|
+
describe('loadTheme', () => {
|
|
53
|
+
it("loadTheme reloads theme properly if it's not yet loaded", () => __awaiter(void 0, void 0, void 0, function* () {
|
|
54
|
+
expect(loadTheme(undefined, true)).resolves.toEqual(undefined);
|
|
55
|
+
}));
|
|
56
|
+
it('loadTheme throws an error if theme param is invalid', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
57
|
+
expect(loadTheme('madeUpTheme')).rejects.toEqual(new Error("We are unable to load the theme, please make sure the theme param is valid"));
|
|
58
|
+
}));
|
|
59
|
+
it('loadTheme throws an error if theme param is invalid', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
60
|
+
expect(loadTheme('jestTestTheme/faltyIndexLoader')).rejects.toEqual(new Error("Unable to retrieve theme index"));
|
|
61
|
+
}));
|
|
62
|
+
it('loadTheme throws an error if loader result is invalid', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
63
|
+
expect(loadTheme('jestTestTheme/faltyIndex')).rejects.toEqual(new Error("Unable to retrieve theme index"));
|
|
64
|
+
}));
|
|
65
|
+
});
|
|
@@ -2,6 +2,6 @@ import type { RouteComponentProps } from "react-router-dom";
|
|
|
2
2
|
export interface IRouteProps {
|
|
3
3
|
path: string;
|
|
4
4
|
}
|
|
5
|
-
export type IProps = RouteComponentProps<IRouteProps>;
|
|
6
|
-
declare const PluginRoute: ({ match: { params: { path }, }, }: IProps) =>
|
|
5
|
+
export declare type IProps = RouteComponentProps<IRouteProps>;
|
|
6
|
+
declare const PluginRoute: ({ match: { params: { path }, }, }: IProps) => JSX.Element;
|
|
7
7
|
export default PluginRoute;
|
|
@@ -9,7 +9,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
11
11
|
import { Suspense, useCallback, useEffect, useState } from "react";
|
|
12
|
-
import { getPluginsAdditionalRoutes } from "../PluginLoader";
|
|
12
|
+
import { getPluginsAdditionalRoutes, loadPlugins } from "../PluginLoader";
|
|
13
13
|
import Shimmer from "../Shimmer";
|
|
14
14
|
const PluginRoute = ({ match: { params: { path }, }, }) => {
|
|
15
15
|
const [RenderComponent, setRenderComponent] = useState(null);
|
|
@@ -17,9 +17,10 @@ const PluginRoute = ({ match: { params: { path }, }, }) => {
|
|
|
17
17
|
try {
|
|
18
18
|
let routes = getPluginsAdditionalRoutes();
|
|
19
19
|
if (!routes.length) {
|
|
20
|
+
yield loadPlugins({ authentication: "1.0.0" });
|
|
20
21
|
routes = getPluginsAdditionalRoutes();
|
|
21
22
|
}
|
|
22
|
-
if (
|
|
23
|
+
if (routes[routePath])
|
|
23
24
|
setRenderComponent(routes[routePath]);
|
|
24
25
|
}
|
|
25
26
|
catch (error) {
|
|
@@ -29,6 +30,6 @@ const PluginRoute = ({ match: { params: { path }, }, }) => {
|
|
|
29
30
|
useEffect(() => {
|
|
30
31
|
loadRouteComponent(path);
|
|
31
32
|
}, [path, loadRouteComponent]);
|
|
32
|
-
return (_jsx(Suspense, { fallback:
|
|
33
|
+
return (_jsx(Suspense, Object.assign({ fallback: () => Shimmer }, { children: _jsx(_Fragment, { children: RenderComponent && _jsx(RenderComponent, {}, void 0) }, void 0) }), void 0));
|
|
33
34
|
};
|
|
34
35
|
export default PluginRoute;
|
|
@@ -2,7 +2,7 @@ import type { Action } from "redux";
|
|
|
2
2
|
import moment from "moment-business-days";
|
|
3
3
|
import { SmartScriptStore } from "../libs/SmartScriptStore";
|
|
4
4
|
import type { StateType } from "../types/State.type";
|
|
5
|
-
export type TInitTriggersCallback = (triggers: StateType.SmartScript["triggers"], actions: Action[]) => void;
|
|
5
|
+
export declare type TInitTriggersCallback = (triggers: StateType.SmartScript["triggers"], actions: Action[]) => void;
|
|
6
6
|
declare global {
|
|
7
7
|
interface Window {
|
|
8
8
|
onInit: typeof SmartScriptStore.onInit;
|
|
@@ -27,5 +27,9 @@ declare global {
|
|
|
27
27
|
initTriggers: (callback: TInitTriggersCallback, inputs: StateType.Inputs, newInstance: boolean) => void;
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
|
-
declare const _default: import("react-redux").ConnectedComponent<
|
|
30
|
+
declare const _default: import("react-redux").ConnectedComponent<({ inpiActivities }: {
|
|
31
|
+
inpiActivities?: never[] | undefined;
|
|
32
|
+
}) => JSX.Element, import("react-redux").Omit<{
|
|
33
|
+
inpiActivities?: never[] | undefined;
|
|
34
|
+
}, never>>;
|
|
31
35
|
export default _default;
|
|
@@ -111,7 +111,7 @@ const SmartScriptComponent = ({ inpiActivities = [] }) => {
|
|
|
111
111
|
}
|
|
112
112
|
return SmartScriptStore.grabActions();
|
|
113
113
|
});
|
|
114
|
-
return _jsx(_Fragment, { children: smartScriptLoaded ? "SmartScript" : "Loading..." });
|
|
114
|
+
return _jsx(_Fragment, { children: smartScriptLoaded ? "SmartScript" : "Loading..." }, void 0);
|
|
115
115
|
};
|
|
116
116
|
const mapStateToProps = () => {
|
|
117
117
|
const inpiActivities = selectDataSmartscript();
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, Fragment as _Fragment } from "react/jsx-runtime";
|
|
2
2
|
import { replaceComponent } from "../../PluginLoader";
|
|
3
|
-
const UserLockedComponent = ({ unhealthyStyle }) => (_jsx("div", { style: unhealthyStyle, children: "Merci d\u2018avoir compl\u00E9t\u00E9 votre questionnaire ! Votre Expert-Comptable a \u00E9t\u00E9 notifi\u00E9 de vos r\u00E9ponses et vous contactera pour la suite de la proc\u00E9dure" }));
|
|
3
|
+
const UserLockedComponent = ({ unhealthyStyle }) => (_jsx("div", Object.assign({ style: unhealthyStyle }, { children: "Merci d\u2018avoir compl\u00E9t\u00E9 votre questionnaire ! Votre Expert-Comptable a \u00E9t\u00E9 notifi\u00E9 de vos r\u00E9ponses et vous contactera pour la suite de la proc\u00E9dure" }), void 0));
|
|
4
4
|
const UserLockHooc = (Component) => (props) => {
|
|
5
5
|
const replaceAnchors = ["UserLockedComponent"];
|
|
6
6
|
const FinalComponent = replaceComponent(replaceAnchors, Component);
|
|
7
|
-
return (_jsx(_Fragment, { children: _jsx(FinalComponent, Object.assign({}, props)) }));
|
|
7
|
+
return (_jsx(_Fragment, { children: _jsx(FinalComponent, Object.assign({}, props), void 0) }, void 0));
|
|
8
8
|
};
|
|
9
9
|
export default UserLockHooc(UserLockedComponent);
|