@legalplace/wizardx-core 4.42.10-nightly.20251126120203 → 4.42.10-nightly.20251126141528
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/App.js +4 -3
- package/dist/components/RouteWatcher.js +25 -14
- package/dist/libs/PathReader.js +18 -11
- package/dist/redux/middlewares/paginationWatcherMiddleware.d.ts +13 -1
- package/dist/redux/middlewares/paginationWatcherMiddleware.js +1 -1
- package/dist/redux/reducers/router.d.ts +11 -0
- package/dist/redux/reducers/router.js +15 -0
- package/dist/redux/sagas/fetchModel.js +7 -1
- package/dist/redux/store.js +17 -3
- package/dist/types/State.type.d.ts +11 -1
- package/package.json +1 -1
package/dist/App.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
2
|
import React from "react";
|
|
3
|
-
import {
|
|
3
|
+
import { Router, Route, Switch, Redirect } from "react-router-dom";
|
|
4
4
|
import { Provider } from "react-redux";
|
|
5
5
|
import { getStore, createAppStore } from "./redux/store";
|
|
6
|
+
import { getHistory } from "./redux/routerHistory";
|
|
6
7
|
import Globals, { setGlobals } from "./Globals";
|
|
7
8
|
import { getConfig, updateConfig } from "./config";
|
|
8
9
|
import { fetchModelPrerequisitesAction } from "./redux/actions/sagas/model";
|
|
@@ -33,7 +34,7 @@ class WizardXCore extends React.Component {
|
|
|
33
34
|
var _a;
|
|
34
35
|
super(props);
|
|
35
36
|
clearPlugins();
|
|
36
|
-
const historyType = "
|
|
37
|
+
const historyType = typeof props.historyType === "string" ? props.historyType : "browser";
|
|
37
38
|
const params = Object.assign(Object.assign({}, Globals), { loadTheme: props.loadTheme, loadPlugin: props.loadPlugin });
|
|
38
39
|
if (props.model) {
|
|
39
40
|
params.model = props.model;
|
|
@@ -76,7 +77,7 @@ class WizardXCore extends React.Component {
|
|
|
76
77
|
getStore().dispatch(resetStateAction());
|
|
77
78
|
}
|
|
78
79
|
render() {
|
|
79
|
-
return (_jsx(Provider, { store: getStore(), children: _jsxs(
|
|
80
|
+
return (_jsx(Provider, { store: getStore(), children: _jsxs(Router, { history: getHistory(), children: [_jsx(RouteWatcher, {}), _jsxs(Switch, { children: [_jsx(Route, { path: "/p/:path", component: PluginRoute }), _jsx(Route, { path: getConfig().router.smartscriptPath, exact: true, strict: true, component: SmartScriptComponent }), _jsx(Route, { path: getConfig().router.wizardInstancePath, component: ViewComponent }), _jsx(Route, { path: getConfig().router.wizardPath, component: ViewComponent }), !window.location.href.includes("smartscript") && (_jsx(Route, { component: RedirectHandler }))] })] }) }));
|
|
80
81
|
}
|
|
81
82
|
}
|
|
82
83
|
export default WizardXCore;
|
|
@@ -1,23 +1,34 @@
|
|
|
1
|
-
import { useEffect } from "react";
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
2
|
import { useLocation } from "react-router-dom";
|
|
3
|
-
import { useDispatch } from "react-redux";
|
|
3
|
+
import { useDispatch, useSelector } from "react-redux";
|
|
4
4
|
const RouteWatcher = () => {
|
|
5
5
|
const location = useLocation();
|
|
6
6
|
const dispatch = useDispatch();
|
|
7
|
+
const isFirstRender = useRef(true);
|
|
8
|
+
const routerLocation = useSelector((state) => { var _a; return (_a = state.router) === null || _a === void 0 ? void 0 : _a.location; });
|
|
7
9
|
useEffect(() => {
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
10
|
+
const hasChanged = !routerLocation ||
|
|
11
|
+
routerLocation.pathname !== location.pathname ||
|
|
12
|
+
routerLocation.search !== location.search ||
|
|
13
|
+
routerLocation.hash !== location.hash;
|
|
14
|
+
if (hasChanged) {
|
|
15
|
+
dispatch({
|
|
16
|
+
type: "@@router/LOCATION_CHANGE",
|
|
17
|
+
payload: {
|
|
18
|
+
location: {
|
|
19
|
+
pathname: location.pathname,
|
|
20
|
+
search: location.search,
|
|
21
|
+
hash: location.hash,
|
|
22
|
+
},
|
|
23
|
+
action: isFirstRender.current ? "POP" : "PUSH",
|
|
24
|
+
isFirstRendering: isFirstRender.current,
|
|
15
25
|
},
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
if (isFirstRender.current) {
|
|
29
|
+
isFirstRender.current = false;
|
|
30
|
+
}
|
|
31
|
+
}, [location.pathname, location.search, location.hash, dispatch, routerLocation]);
|
|
21
32
|
return null;
|
|
22
33
|
};
|
|
23
34
|
export default RouteWatcher;
|
package/dist/libs/PathReader.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { createMatchSelector } from "connected-react-router";
|
|
2
1
|
import queryString from "query-string";
|
|
3
2
|
import { matchPath, generatePath } from "react-router";
|
|
4
3
|
import { getConfig } from "../config";
|
|
@@ -19,12 +18,16 @@ export class PathReader {
|
|
|
19
18
|
}
|
|
20
19
|
}
|
|
21
20
|
matchWithoutUniqId(state) {
|
|
22
|
-
var _a;
|
|
23
|
-
const
|
|
24
|
-
const matchResult =
|
|
25
|
-
|
|
21
|
+
var _a, _b, _c;
|
|
22
|
+
const pathname = ((_b = (_a = state.router) === null || _a === void 0 ? void 0 : _a.location) === null || _b === void 0 ? void 0 : _b.pathname) || window.location.pathname;
|
|
23
|
+
const matchResult = matchPath(pathname, {
|
|
24
|
+
path: getConfig().router.wizardPath,
|
|
25
|
+
exact: false,
|
|
26
|
+
strict: false,
|
|
27
|
+
});
|
|
28
|
+
if (matchResult && matchResult.params) {
|
|
26
29
|
const { permalink, page, view, prefix } = matchResult.params;
|
|
27
|
-
const modelVersion = (
|
|
30
|
+
const modelVersion = (_c = getQueryStringValues()) === null || _c === void 0 ? void 0 : _c.version;
|
|
28
31
|
this.currentPrefix = prefix || "";
|
|
29
32
|
this.currentPermalink = Globals.permalink || permalink;
|
|
30
33
|
this.currentPage = this.getPageNumber(page);
|
|
@@ -36,12 +39,16 @@ export class PathReader {
|
|
|
36
39
|
}
|
|
37
40
|
}
|
|
38
41
|
matchWithUniqId(state) {
|
|
39
|
-
var _a;
|
|
40
|
-
const
|
|
41
|
-
const matchResult =
|
|
42
|
-
|
|
42
|
+
var _a, _b, _c;
|
|
43
|
+
const pathname = ((_b = (_a = state.router) === null || _a === void 0 ? void 0 : _a.location) === null || _b === void 0 ? void 0 : _b.pathname) || window.location.pathname;
|
|
44
|
+
const matchResult = matchPath(pathname, {
|
|
45
|
+
path: getConfig().router.wizardInstancePath,
|
|
46
|
+
exact: false,
|
|
47
|
+
strict: false,
|
|
48
|
+
});
|
|
49
|
+
if (matchResult && matchResult.params) {
|
|
43
50
|
const { permalink, page, uniqid, view, prefix } = matchResult.params;
|
|
44
|
-
const modelVersion = (
|
|
51
|
+
const modelVersion = (_c = getQueryStringValues()) === null || _c === void 0 ? void 0 : _c.version;
|
|
45
52
|
this.currentPermalink = Globals.permalink || permalink;
|
|
46
53
|
this.currentPrefix = prefix || "";
|
|
47
54
|
this.currentPage = this.getPageNumber(page);
|
|
@@ -1,5 +1,17 @@
|
|
|
1
|
-
import type { LocationChangeAction } from "connected-react-router";
|
|
2
1
|
import type { MiddlewareAPI, Dispatch } from "redux";
|
|
2
|
+
declare const LOCATION_CHANGE = "@@router/LOCATION_CHANGE";
|
|
3
|
+
interface LocationChangeAction {
|
|
4
|
+
type: typeof LOCATION_CHANGE;
|
|
5
|
+
payload: {
|
|
6
|
+
location: {
|
|
7
|
+
pathname: string;
|
|
8
|
+
search: string;
|
|
9
|
+
hash: string;
|
|
10
|
+
};
|
|
11
|
+
action: string;
|
|
12
|
+
isFirstRendering: boolean;
|
|
13
|
+
};
|
|
14
|
+
}
|
|
3
15
|
import type { ActionsType } from "../../types/Actions.type";
|
|
4
16
|
export type WatcherActions = ActionsType.Conditions.updateSectionCondition | LocationChangeAction;
|
|
5
17
|
declare const paginationWatcherMiddleware: (mpi: MiddlewareAPI) => (next: Dispatch) => (action: WatcherActions) => any;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
const LOCATION_CHANGE = "@@router/LOCATION_CHANGE";
|
|
2
2
|
import { goPageAction, updateAvailableSectionsAction, initMetaAction, initInstanceAction, } from "../actions/app";
|
|
3
3
|
import { UPDATE_SECTION_CONDITION } from "../constants/conditions";
|
|
4
4
|
import { selectAllSectionsReferences, selectUserEmailSectionVariableIds, } from "../selectors/references";
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export interface RouterLocation {
|
|
2
|
+
pathname: string;
|
|
3
|
+
search: string;
|
|
4
|
+
hash: string;
|
|
5
|
+
}
|
|
6
|
+
export interface RouterState {
|
|
7
|
+
location: RouterLocation;
|
|
8
|
+
action: string;
|
|
9
|
+
}
|
|
10
|
+
declare const routerReducer: (state: RouterState | undefined, action: any) => RouterState;
|
|
11
|
+
export default routerReducer;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
const initialState = {
|
|
2
|
+
location: {
|
|
3
|
+
pathname: typeof window !== "undefined" ? window.location.pathname : "/",
|
|
4
|
+
search: typeof window !== "undefined" ? window.location.search : "",
|
|
5
|
+
hash: typeof window !== "undefined" ? window.location.hash : "",
|
|
6
|
+
},
|
|
7
|
+
action: "POP",
|
|
8
|
+
};
|
|
9
|
+
const routerReducer = (state = initialState, action) => {
|
|
10
|
+
if (action.type === "@@router/LOCATION_CHANGE") {
|
|
11
|
+
return Object.assign(Object.assign({}, state), { location: action.payload.location, action: action.payload.action || "PUSH" });
|
|
12
|
+
}
|
|
13
|
+
return state;
|
|
14
|
+
};
|
|
15
|
+
export default routerReducer;
|
|
@@ -237,7 +237,7 @@ function* createInstance(enableShadowInstance, modelInformation, uniqid, permali
|
|
|
237
237
|
yield put(initInstanceAction(instance));
|
|
238
238
|
}
|
|
239
239
|
function* fetchModelPrerequisites(action) {
|
|
240
|
-
|
|
240
|
+
let { permalink, prefix } = action;
|
|
241
241
|
if (!permalink && window.location.href.includes("smartscript"))
|
|
242
242
|
return;
|
|
243
243
|
const uniqid = selectInstanceUniqid() || getConfig().uniqid;
|
|
@@ -245,6 +245,12 @@ function* fetchModelPrerequisites(action) {
|
|
|
245
245
|
const urlParams = new URLSearchParams(window.location.search);
|
|
246
246
|
const state = yield select((s) => s);
|
|
247
247
|
const pathReader = new PathReader(state);
|
|
248
|
+
if (!permalink || permalink.trim() === "") {
|
|
249
|
+
permalink = pathReader.currentPermalink || "";
|
|
250
|
+
}
|
|
251
|
+
if (!prefix || prefix.trim() === "") {
|
|
252
|
+
prefix = pathReader.currentPrefix || "";
|
|
253
|
+
}
|
|
248
254
|
const queryParams = new URLSearchParams(window.location.search);
|
|
249
255
|
if (pathReader.modelVersion)
|
|
250
256
|
queryParams.set("version", pathReader.modelVersion);
|
package/dist/redux/store.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { combineReducers, legacy_createStore as createStore, applyMiddleware } from "redux";
|
|
2
|
-
import { connectRouter, routerMiddleware } from "connected-react-router";
|
|
3
2
|
import { composeWithDevTools } from "redux-devtools-extension";
|
|
4
3
|
import { appReducer } from "./reducers/app";
|
|
5
4
|
import { userReducer } from "./reducers/user";
|
|
@@ -24,6 +23,7 @@ import smartscriptMiddleware from "./middlewares/smartscriptMiddleware";
|
|
|
24
23
|
import thirdPartyScriptsMiddleware from "./middlewares/thirdpartyScriptsMiddleware";
|
|
25
24
|
import { pluginsStoreReducer } from "./reducers/pluginsStore";
|
|
26
25
|
import { getSagaMiddleware } from "./sagas/middleware";
|
|
26
|
+
import routerReducer from "./reducers/router";
|
|
27
27
|
let store;
|
|
28
28
|
export const createAppStore = (historyType = "browser") => {
|
|
29
29
|
if (store !== undefined) {
|
|
@@ -32,7 +32,7 @@ export const createAppStore = (historyType = "browser") => {
|
|
|
32
32
|
}
|
|
33
33
|
const history = createHistory(historyType);
|
|
34
34
|
const wizardxReducers = combineReducers({
|
|
35
|
-
router:
|
|
35
|
+
router: routerReducer,
|
|
36
36
|
app: appReducer,
|
|
37
37
|
user: userReducer,
|
|
38
38
|
references: referencesReducer,
|
|
@@ -43,7 +43,7 @@ export const createAppStore = (historyType = "browser") => {
|
|
|
43
43
|
pluginsStore: pluginsStoreReducer,
|
|
44
44
|
});
|
|
45
45
|
const sagaMiddleware = getSagaMiddleware();
|
|
46
|
-
const appliedMiddlewares = applyMiddleware(pluginsHookMiddleware,
|
|
46
|
+
const appliedMiddlewares = applyMiddleware(pluginsHookMiddleware, sagaMiddleware, paginationWatcherMiddleware, selectorsMiddleware, conditionsWatcherMiddleware, prefillerWatcherMiddleware, evaluationsWatcherMiddleware, multiplesActionsMiddleware, mandatoriesWatcherMiddleware, smartscriptMiddleware, thirdPartyScriptsMiddleware);
|
|
47
47
|
const middlewares = Globals.appEnv !== "production"
|
|
48
48
|
? composeWithDevTools(appliedMiddlewares)
|
|
49
49
|
: appliedMiddlewares;
|
|
@@ -51,6 +51,20 @@ export const createAppStore = (historyType = "browser") => {
|
|
|
51
51
|
sagasRunner(sagaMiddleware);
|
|
52
52
|
subscribeListeners(store);
|
|
53
53
|
store.dispatch({ type: "@@WIZARDX/INIT" });
|
|
54
|
+
if (typeof window !== "undefined") {
|
|
55
|
+
store.dispatch({
|
|
56
|
+
type: "@@router/LOCATION_CHANGE",
|
|
57
|
+
payload: {
|
|
58
|
+
location: {
|
|
59
|
+
pathname: window.location.pathname,
|
|
60
|
+
search: window.location.search,
|
|
61
|
+
hash: window.location.hash,
|
|
62
|
+
},
|
|
63
|
+
action: "POP",
|
|
64
|
+
isFirstRendering: true,
|
|
65
|
+
},
|
|
66
|
+
});
|
|
67
|
+
}
|
|
54
68
|
};
|
|
55
69
|
export const getStore = (throwIfDoesNotExist = true) => {
|
|
56
70
|
if (store === undefined && throwIfDoesNotExist)
|
|
@@ -14,8 +14,18 @@ export type MAPPED_CONDITIONS = {
|
|
|
14
14
|
};
|
|
15
15
|
conditions: ConditionV3;
|
|
16
16
|
};
|
|
17
|
+
export interface RouterStateType {
|
|
18
|
+
location: {
|
|
19
|
+
pathname: string;
|
|
20
|
+
search: string;
|
|
21
|
+
hash: string;
|
|
22
|
+
key?: string;
|
|
23
|
+
state?: any;
|
|
24
|
+
};
|
|
25
|
+
action: string;
|
|
26
|
+
}
|
|
17
27
|
export interface StateType {
|
|
18
|
-
router:
|
|
28
|
+
router: RouterStateType;
|
|
19
29
|
app: AppType;
|
|
20
30
|
user?: UserType;
|
|
21
31
|
inputs: InputsType;
|