@legalplace/wizardx-core 4.42.10-nightly.20251125115613 → 4.42.10-nightly.20251125120616
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/WizardCore.d.ts +6 -2
- package/dist/WizardCore.js +64 -30
- package/dist/redux/store.d.ts +3 -1
- package/dist/redux/store.js +2 -1
- package/dist/routing/adapters/nextjs.adapter.js +4 -6
- package/dist/routing/adapters/reactRouter.adapter.js +16 -19
- package/dist/routing/context.js +1 -3
- package/dist/routing/index.d.ts +1 -1
- package/dist/routing/index.js +1 -1
- package/package.json +1 -1
package/dist/WizardCore.d.ts
CHANGED
|
@@ -16,10 +16,14 @@ export interface WizardCoreProps {
|
|
|
16
16
|
routerAdapter?: IRouterAdapter;
|
|
17
17
|
routing?: IWizardCoreRouterProps;
|
|
18
18
|
}
|
|
19
|
-
declare class WizardCore extends React.Component<WizardCoreProps
|
|
19
|
+
declare class WizardCore extends React.Component<WizardCoreProps, {
|
|
20
|
+
initialized: boolean;
|
|
21
|
+
}> {
|
|
22
|
+
private storeInitialized;
|
|
20
23
|
constructor(props: WizardCoreProps);
|
|
24
|
+
private initializeStore;
|
|
21
25
|
componentDidMount(): void;
|
|
22
26
|
componentWillUnmount(): void;
|
|
23
|
-
render(): import("react/jsx-runtime").JSX.Element;
|
|
27
|
+
render(): import("react/jsx-runtime").JSX.Element | null;
|
|
24
28
|
}
|
|
25
29
|
export default WizardCore;
|
package/dist/WizardCore.js
CHANGED
|
@@ -50,8 +50,17 @@ const RedirectHandler = ({ navigate, }) => {
|
|
|
50
50
|
};
|
|
51
51
|
class WizardCore extends React.Component {
|
|
52
52
|
constructor(props) {
|
|
53
|
-
var _a;
|
|
54
53
|
super(props);
|
|
54
|
+
this.storeInitialized = false;
|
|
55
|
+
this.state = {
|
|
56
|
+
initialized: false,
|
|
57
|
+
};
|
|
58
|
+
this.initializeStore(props);
|
|
59
|
+
}
|
|
60
|
+
initializeStore(props) {
|
|
61
|
+
var _a;
|
|
62
|
+
if (this.storeInitialized)
|
|
63
|
+
return;
|
|
55
64
|
clearPlugins();
|
|
56
65
|
const historyType = typeof props.historyType === "string" ? props.historyType : "browser";
|
|
57
66
|
const params = Object.assign(Object.assign({}, Globals), { loadTheme: props.loadTheme, loadPlugin: props.loadPlugin });
|
|
@@ -72,48 +81,73 @@ class WizardCore extends React.Component {
|
|
|
72
81
|
updateConfig(props.wizardParams);
|
|
73
82
|
if (props.preloadTheme && ((_a = props.wizardParams) === null || _a === void 0 ? void 0 : _a.theme.name))
|
|
74
83
|
preloadTheme(props.wizardParams.theme.name);
|
|
75
|
-
|
|
84
|
+
try {
|
|
85
|
+
createAppStore(historyType);
|
|
86
|
+
this.storeInitialized = true;
|
|
87
|
+
}
|
|
88
|
+
catch (error) {
|
|
89
|
+
console.error("Failed to initialize store:", error);
|
|
90
|
+
}
|
|
76
91
|
}
|
|
77
92
|
componentDidMount() {
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
93
|
+
if (!this.storeInitialized) {
|
|
94
|
+
this.initializeStore(this.props);
|
|
95
|
+
}
|
|
96
|
+
setTimeout(() => {
|
|
97
|
+
try {
|
|
98
|
+
const { dispatch, getState } = getStore();
|
|
99
|
+
const state = getState();
|
|
100
|
+
let parent = null;
|
|
101
|
+
window.addEventListener("message", ({ data, source }) => {
|
|
102
|
+
if (parent === null || data.from === "BO") {
|
|
103
|
+
parent = source;
|
|
104
|
+
}
|
|
105
|
+
if (data.from && data.from === "BO") {
|
|
106
|
+
const { variables } = data;
|
|
107
|
+
autoSave(variables, getStore());
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
dispatch(callInitDataSmartscriptAction());
|
|
111
|
+
if (!PathReader.isSmartScriptPath()) {
|
|
112
|
+
dispatch(fetchModelPrerequisitesAction(getConfig().permalink || state.app.meta.permalink, getConfig().prefix || state.app.meta.prefix || ""));
|
|
113
|
+
}
|
|
114
|
+
this.setState({ initialized: true });
|
|
84
115
|
}
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
autoSave(variables, getStore());
|
|
116
|
+
catch (error) {
|
|
117
|
+
console.error("Error during component mount:", error);
|
|
88
118
|
}
|
|
89
|
-
});
|
|
90
|
-
dispatch(callInitDataSmartscriptAction());
|
|
91
|
-
if (!PathReader.isSmartScriptPath()) {
|
|
92
|
-
dispatch(fetchModelPrerequisitesAction(getConfig().permalink || state.app.meta.permalink, getConfig().prefix || state.app.meta.prefix || ""));
|
|
93
|
-
}
|
|
119
|
+
}, 0);
|
|
94
120
|
}
|
|
95
121
|
componentWillUnmount() {
|
|
96
122
|
getStore().dispatch(resetStateAction());
|
|
97
123
|
}
|
|
98
124
|
render() {
|
|
125
|
+
if (!this.storeInitialized) {
|
|
126
|
+
return null;
|
|
127
|
+
}
|
|
99
128
|
const { routerAdapter, routing } = this.props;
|
|
100
|
-
|
|
101
|
-
const
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
const
|
|
105
|
-
|
|
129
|
+
try {
|
|
130
|
+
const store = getStore();
|
|
131
|
+
if (routing) {
|
|
132
|
+
const { pathname, params, navigate } = routing;
|
|
133
|
+
const routeMatch = getRouteComponent(pathname, params);
|
|
134
|
+
if (routeMatch) {
|
|
135
|
+
const RouteComponent = routeMatch.component;
|
|
136
|
+
return (_jsx(Provider, { store: store, children: _jsx(RouteComponent, Object.assign({}, (routeMatch.props || {}))) }));
|
|
137
|
+
}
|
|
138
|
+
return (_jsx(Provider, { store: store, children: _jsx(RedirectHandler, { navigate: navigate }) }));
|
|
106
139
|
}
|
|
107
|
-
|
|
140
|
+
if (routerAdapter) {
|
|
141
|
+
return (_jsx(Provider, { store: store, children: _jsx(RouterProvider, { adapter: routerAdapter, children: _jsx(WizardCoreContent, {}) }) }));
|
|
142
|
+
}
|
|
143
|
+
console.warn("WizardCore: No routing mechanism provided. Pass either 'routerAdapter' or 'routing' props.");
|
|
144
|
+
return (_jsx(Provider, { store: store, children: _jsx("div", { children: "No routing configured" }) }));
|
|
108
145
|
}
|
|
109
|
-
|
|
110
|
-
|
|
146
|
+
catch (error) {
|
|
147
|
+
console.error("Error rendering WizardCore:", error);
|
|
148
|
+
return _jsx("div", { children: "Error initializing wizard. Check console for details." });
|
|
111
149
|
}
|
|
112
|
-
console.warn("WizardCore: No routing mechanism provided. Pass either 'routerAdapter' or 'routing' props.");
|
|
113
|
-
return (_jsx(Provider, { store: getStore(), children: _jsx("div", { children: "No routing configured" }) }));
|
|
114
150
|
}
|
|
115
151
|
}
|
|
116
|
-
const WizardCoreContent = () => {
|
|
117
|
-
return _jsx(ViewComponent, {});
|
|
118
|
-
};
|
|
152
|
+
const WizardCoreContent = () => (_jsx(ViewComponent, {}));
|
|
119
153
|
export default WizardCore;
|
package/dist/redux/store.d.ts
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { Store } from "redux";
|
|
2
2
|
import type { StateType } from "../types/State.type";
|
|
3
|
-
export declare const createAppStore: (historyType?: "browser" | "memory") =>
|
|
3
|
+
export declare const createAppStore: (historyType?: "browser" | "memory") => Store<StateType, any> & {
|
|
4
|
+
dispatch: unknown;
|
|
5
|
+
};
|
|
4
6
|
export declare const getStore: (throwIfDoesNotExist?: boolean) => Store<StateType, any> & {
|
|
5
7
|
dispatch: unknown;
|
|
6
8
|
};
|
package/dist/redux/store.js
CHANGED
|
@@ -28,7 +28,7 @@ let store;
|
|
|
28
28
|
export const createAppStore = (historyType = "browser") => {
|
|
29
29
|
if (store !== undefined) {
|
|
30
30
|
createHistory(historyType);
|
|
31
|
-
return;
|
|
31
|
+
return store;
|
|
32
32
|
}
|
|
33
33
|
const history = createHistory(historyType);
|
|
34
34
|
const wizardxReducers = combineReducers({
|
|
@@ -50,6 +50,7 @@ export const createAppStore = (historyType = "browser") => {
|
|
|
50
50
|
store = createStore(wizardxReducers, middlewares);
|
|
51
51
|
sagasRunner(sagaMiddleware);
|
|
52
52
|
subscribeListeners(store);
|
|
53
|
+
return store;
|
|
53
54
|
};
|
|
54
55
|
export const getStore = (throwIfDoesNotExist = true) => {
|
|
55
56
|
if (store === undefined && throwIfDoesNotExist)
|
|
@@ -21,12 +21,10 @@ export const createNextJSAdapter = (router, pathname, searchParams, params) => {
|
|
|
21
21
|
}, [params]);
|
|
22
22
|
return {
|
|
23
23
|
useParams: () => normalizedParams,
|
|
24
|
-
useNavigate: () => {
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
}
|
|
29
|
-
};
|
|
24
|
+
useNavigate: () => (path) => {
|
|
25
|
+
if (router === null || router === void 0 ? void 0 : router.push) {
|
|
26
|
+
router.push(path);
|
|
27
|
+
}
|
|
30
28
|
},
|
|
31
29
|
useLocation: () => ({
|
|
32
30
|
pathname,
|
|
@@ -1,19 +1,16 @@
|
|
|
1
|
-
import { useParams as useParamsRR, useHistory, useLocation as useLocationRR, } from "react-router-dom";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
Link: LinkRR,
|
|
18
|
-
};
|
|
19
|
-
};
|
|
1
|
+
import { useParams as useParamsRR, useHistory, useLocation as useLocationRR, Link as LinkRR, } from "react-router-dom";
|
|
2
|
+
export const createReactRouterAdapter = () => ({
|
|
3
|
+
useParams: () => useParamsRR(),
|
|
4
|
+
useNavigate: () => {
|
|
5
|
+
const history = useHistory();
|
|
6
|
+
return (path) => history.push(path);
|
|
7
|
+
},
|
|
8
|
+
useLocation: () => {
|
|
9
|
+
const location = useLocationRR();
|
|
10
|
+
return {
|
|
11
|
+
pathname: location.pathname,
|
|
12
|
+
search: location.search,
|
|
13
|
+
};
|
|
14
|
+
},
|
|
15
|
+
Link: LinkRR,
|
|
16
|
+
});
|
package/dist/routing/context.js
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
2
|
import { createContext, useContext } from "react";
|
|
3
3
|
const RouterContext = createContext(null);
|
|
4
|
-
export const RouterProvider = ({ adapter, children, }) => {
|
|
5
|
-
return (_jsx(RouterContext.Provider, { value: adapter, children: children }));
|
|
6
|
-
};
|
|
4
|
+
export const RouterProvider = ({ adapter, children, }) => (_jsx(RouterContext.Provider, { value: adapter, children: children }));
|
|
7
5
|
export const useRouterAdapter = () => {
|
|
8
6
|
const adapter = useContext(RouterContext);
|
|
9
7
|
if (!adapter) {
|
package/dist/routing/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from "./types";
|
|
2
2
|
export * from "./context";
|
|
3
3
|
export { createReactRouterAdapter } from "./adapters/reactRouter.adapter";
|
|
4
|
-
export { createNextJSAdapter, useNextJSAdapter } from "./adapters/nextjs.adapter";
|
|
4
|
+
export { createNextJSAdapter, useNextJSAdapter, } from "./adapters/nextjs.adapter";
|
package/dist/routing/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export * from "./types";
|
|
2
2
|
export * from "./context";
|
|
3
3
|
export { createReactRouterAdapter } from "./adapters/reactRouter.adapter";
|
|
4
|
-
export { createNextJSAdapter, useNextJSAdapter } from "./adapters/nextjs.adapter";
|
|
4
|
+
export { createNextJSAdapter, useNextJSAdapter, } from "./adapters/nextjs.adapter";
|