@legalplace/wizardx-core 4.42.10-nightly.20251125161848 → 4.42.10-nightly.20251126115357
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 +35 -105
- package/dist/{WizardCore.d.ts → AppNextJS.d.ts} +5 -11
- package/dist/AppNextJS.js +81 -0
- package/dist/index.d.ts +2 -3
- package/dist/index.js +2 -3
- package/package.json +6 -12
- package/dist/WizardCore.js +0 -149
- 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/routing/types.js +0 -1
- package/dist/wizardcore.entry.d.ts +0 -3
- package/dist/wizardcore.entry.js +0 -2
package/README.md
CHANGED
|
@@ -9,15 +9,9 @@ Core library for WizardX - A powerful, themeable, and extensible wizard framewor
|
|
|
9
9
|
- 📱 **Responsive**: Mobile-first design
|
|
10
10
|
- 🔄 **State Management**: Redux-based state management with sagas
|
|
11
11
|
- 🎯 **Type-Safe**: Full TypeScript support
|
|
12
|
-
- 🚀 **
|
|
12
|
+
- 🚀 **React Router**: Client-side routing with React Router v5
|
|
13
13
|
- 📦 **Tree-Shakeable**: Optimized bundle size
|
|
14
|
-
|
|
15
|
-
## 🆕 NEW: Multi-Router Support
|
|
16
|
-
|
|
17
|
-
WizardX Core now supports multiple routing solutions! Use it with:
|
|
18
|
-
- ✅ **React Router v5** (CRA) - Existing implementation
|
|
19
|
-
- ✅ **Next.js 15 App Router** - New support
|
|
20
|
-
- 🔮 Extensible to other routers (Remix, Tanstack Router, etc.)
|
|
14
|
+
- ⚡ **Next.js Compatible**: Works with Next.js using URL rewrites
|
|
21
15
|
|
|
22
16
|
## 📦 Installation
|
|
23
17
|
|
|
@@ -27,7 +21,7 @@ pnpm add @legalplace/wizardx-core
|
|
|
27
21
|
|
|
28
22
|
## 🚀 Quick Start
|
|
29
23
|
|
|
30
|
-
### For Create React App
|
|
24
|
+
### For Create React App
|
|
31
25
|
|
|
32
26
|
```tsx
|
|
33
27
|
import { App } from "@legalplace/wizardx-core";
|
|
@@ -44,25 +38,16 @@ root.render(
|
|
|
44
38
|
);
|
|
45
39
|
```
|
|
46
40
|
|
|
47
|
-
### For Next.js
|
|
41
|
+
### For Next.js (with URL Rewrite)
|
|
48
42
|
|
|
49
43
|
```tsx
|
|
44
|
+
// app/wizard/page.tsx
|
|
50
45
|
'use client';
|
|
51
|
-
import {
|
|
52
|
-
import { createNextJSAdapter } from "@legalplace/wizardx-core/routing";
|
|
53
|
-
import { useRouter, usePathname, useSearchParams, useParams } from "next/navigation";
|
|
46
|
+
import { AppNextJS } from "@legalplace/wizardx-core";
|
|
54
47
|
|
|
55
48
|
export default function WizardPage() {
|
|
56
|
-
const adapter = createNextJSAdapter(
|
|
57
|
-
useRouter(),
|
|
58
|
-
usePathname(),
|
|
59
|
-
useSearchParams(),
|
|
60
|
-
useParams()
|
|
61
|
-
);
|
|
62
|
-
|
|
63
49
|
return (
|
|
64
|
-
<
|
|
65
|
-
routerAdapter={adapter}
|
|
50
|
+
<AppNextJS
|
|
66
51
|
loadPlugin={loadPlugin}
|
|
67
52
|
loadTheme={loadTheme}
|
|
68
53
|
wizardParams={wizardParams}
|
|
@@ -71,25 +56,22 @@ export default function WizardPage() {
|
|
|
71
56
|
}
|
|
72
57
|
```
|
|
73
58
|
|
|
74
|
-
|
|
59
|
+
**Important**: Use `AppNextJS` instead of `App` for Next.js projects.
|
|
60
|
+
|
|
61
|
+
See [NEXTJS-INTEGRATION.md](./NEXTJS-INTEGRATION.md) for complete Next.js setup including URL rewrites.
|
|
75
62
|
|
|
76
|
-
|
|
77
|
-
- **[Quick Start - Next.js](./QUICK-START-NEXTJS.md)** - 5-minute setup guide for Next.js
|
|
78
|
-
- **[Migration Guide](./MIGRATION-NEXTJS.md)** - Complete migration guide from CRA to Next.js
|
|
79
|
-
- **[Examples](./examples/)** - Working examples and code samples
|
|
63
|
+
## 📚 Documentation
|
|
80
64
|
|
|
81
|
-
|
|
82
|
-
- **[Routing Guide](./README-ROUTING.md)** - In-depth routing architecture
|
|
65
|
+
- **[Next.js Integration](./NEXTJS-INTEGRATION.md)** - Complete guide for Next.js integration with URL rewrites
|
|
83
66
|
- **[Architecture Diagram](./ARCHITECTURE-DIAGRAM.md)** - Visual architecture overview
|
|
84
|
-
- **[Changelog
|
|
85
|
-
- **[Solution Summary](./ROUTING-SOLUTION-SUMMARY.md)** - Complete solution overview
|
|
67
|
+
- **[Changelog](./CHANGELOG.md)** - Version history and changes
|
|
86
68
|
|
|
87
69
|
## 🎯 Core Concepts
|
|
88
70
|
|
|
89
71
|
### Components
|
|
90
72
|
|
|
91
73
|
#### `App` Component
|
|
92
|
-
The
|
|
74
|
+
The main component for Create React App that uses React Router with ConnectedRouter.
|
|
93
75
|
|
|
94
76
|
```tsx
|
|
95
77
|
import { App } from "@legalplace/wizardx-core";
|
|
@@ -104,18 +86,18 @@ import { App } from "@legalplace/wizardx-core";
|
|
|
104
86
|
/>
|
|
105
87
|
```
|
|
106
88
|
|
|
107
|
-
#### `
|
|
108
|
-
|
|
89
|
+
#### `AppNextJS` Component
|
|
90
|
+
Optimized component for Next.js that uses BrowserRouter instead of ConnectedRouter.
|
|
109
91
|
|
|
110
92
|
```tsx
|
|
111
|
-
import {
|
|
112
|
-
import { createNextJSAdapter } from "@legalplace/wizardx-core/routing";
|
|
93
|
+
import { AppNextJS } from "@legalplace/wizardx-core";
|
|
113
94
|
|
|
114
|
-
<
|
|
115
|
-
routerAdapter={adapter} // or use 'routing' prop for manual control
|
|
95
|
+
<AppNextJS
|
|
116
96
|
loadPlugin={loadPlugin}
|
|
117
97
|
loadTheme={loadTheme}
|
|
118
98
|
wizardParams={wizardParams}
|
|
99
|
+
model={initialModel}
|
|
100
|
+
user={user}
|
|
119
101
|
/>
|
|
120
102
|
```
|
|
121
103
|
|
|
@@ -182,60 +164,12 @@ const wizardParams = {
|
|
|
182
164
|
};
|
|
183
165
|
```
|
|
184
166
|
|
|
185
|
-
## 🔌 Router Adapters
|
|
186
|
-
|
|
187
|
-
### React Router Adapter
|
|
188
|
-
|
|
189
|
-
```tsx
|
|
190
|
-
import { createReactRouterAdapter } from "@legalplace/wizardx-core/routing";
|
|
191
|
-
|
|
192
|
-
const adapter = createReactRouterAdapter();
|
|
193
|
-
```
|
|
194
|
-
|
|
195
|
-
### Next.js Adapter
|
|
196
|
-
|
|
197
|
-
```tsx
|
|
198
|
-
import { createNextJSAdapter } from "@legalplace/wizardx-core/routing";
|
|
199
|
-
import { useRouter, usePathname, useSearchParams, useParams } from "next/navigation";
|
|
200
|
-
|
|
201
|
-
const adapter = createNextJSAdapter(
|
|
202
|
-
useRouter(),
|
|
203
|
-
usePathname(),
|
|
204
|
-
useSearchParams(),
|
|
205
|
-
useParams()
|
|
206
|
-
);
|
|
207
|
-
```
|
|
208
|
-
|
|
209
|
-
### Custom Adapter
|
|
210
|
-
|
|
211
|
-
Implement the `IRouterAdapter` interface:
|
|
212
|
-
|
|
213
|
-
```tsx
|
|
214
|
-
interface IRouterAdapter {
|
|
215
|
-
useParams: <T = any>() => T;
|
|
216
|
-
useNavigate: () => (path: string) => void;
|
|
217
|
-
useLocation: () => { pathname: string; search: string };
|
|
218
|
-
Link: ComponentType<LinkProps>;
|
|
219
|
-
}
|
|
220
|
-
```
|
|
221
|
-
|
|
222
167
|
## 📦 Exports
|
|
223
168
|
|
|
224
169
|
```typescript
|
|
225
170
|
// Components
|
|
226
|
-
export { App } from "@legalplace/wizardx-core";
|
|
227
|
-
export {
|
|
228
|
-
|
|
229
|
-
// Routing
|
|
230
|
-
export {
|
|
231
|
-
createReactRouterAdapter,
|
|
232
|
-
createNextJSAdapter,
|
|
233
|
-
RouterProvider,
|
|
234
|
-
useRouterAdapter,
|
|
235
|
-
useParams,
|
|
236
|
-
useNavigate,
|
|
237
|
-
useLocation,
|
|
238
|
-
} from "@legalplace/wizardx-core/routing";
|
|
171
|
+
export { App } from "@legalplace/wizardx-core"; // For CRA
|
|
172
|
+
export { AppNextJS } from "@legalplace/wizardx-core"; // For Next.js
|
|
239
173
|
|
|
240
174
|
// Configuration
|
|
241
175
|
export { getConfig, updateConfig } from "@legalplace/wizardx-core";
|
|
@@ -247,6 +181,12 @@ export { getStore, createAppStore } from "@legalplace/wizardx-core";
|
|
|
247
181
|
export { loadThemeComponent, addOnThemeLoadCallback } from "@legalplace/wizardx-core";
|
|
248
182
|
export { loadPlugin, clearPlugins } from "@legalplace/wizardx-core";
|
|
249
183
|
|
|
184
|
+
// Connectors & Helpers
|
|
185
|
+
export * from "@legalplace/wizardx-core/componentsConnectors";
|
|
186
|
+
export * from "@legalplace/wizardx-core/helpers";
|
|
187
|
+
export * from "@legalplace/wizardx-core/hooks";
|
|
188
|
+
export * from "@legalplace/wizardx-core/types";
|
|
189
|
+
|
|
250
190
|
// ... and many more
|
|
251
191
|
```
|
|
252
192
|
|
|
@@ -259,14 +199,8 @@ export { loadPlugin, clearPlugins } from "@legalplace/wizardx-core";
|
|
|
259
199
|
│
|
|
260
200
|
▼
|
|
261
201
|
┌─────────────────────────────────────┐
|
|
262
|
-
│
|
|
263
|
-
│
|
|
264
|
-
└──────────────┬──────────────────────┘
|
|
265
|
-
│
|
|
266
|
-
▼
|
|
267
|
-
┌─────────────────────────────────────┐
|
|
268
|
-
│ WizardCore / App │
|
|
269
|
-
│ (Business Logic Layer) │
|
|
202
|
+
│ App Component │
|
|
203
|
+
│ (React Router v5) │
|
|
270
204
|
└──────────────┬──────────────────────┘
|
|
271
205
|
│
|
|
272
206
|
▼
|
|
@@ -336,9 +270,7 @@ Full TypeScript support with exported types:
|
|
|
336
270
|
```typescript
|
|
337
271
|
import type {
|
|
338
272
|
AppProps,
|
|
339
|
-
WizardCoreProps,
|
|
340
273
|
IWizardParams,
|
|
341
|
-
IRouterAdapter,
|
|
342
274
|
StateType,
|
|
343
275
|
} from "@legalplace/wizardx-core";
|
|
344
276
|
```
|
|
@@ -364,13 +296,11 @@ MIT
|
|
|
364
296
|
## 📞 Support
|
|
365
297
|
|
|
366
298
|
For issues and questions:
|
|
367
|
-
1. Check the [documentation](./
|
|
368
|
-
2.
|
|
369
|
-
3. Open an issue on GitLab
|
|
299
|
+
1. Check the [documentation](./NEXTJS-INTEGRATION.md)
|
|
300
|
+
2. Open an issue on GitLab
|
|
370
301
|
|
|
371
302
|
---
|
|
372
303
|
|
|
373
|
-
**Version**: 4.
|
|
374
|
-
**Last Updated**: Nov
|
|
375
|
-
**Status**: ✅ Production Ready
|
|
376
|
-
**Multi-Router Support**: ✅ Stable
|
|
304
|
+
**Version**: 4.43.0+
|
|
305
|
+
**Last Updated**: Nov 26, 2025
|
|
306
|
+
**Status**: ✅ Production Ready
|
|
@@ -2,9 +2,7 @@ import React from "react";
|
|
|
2
2
|
import type { ModelV3 } from "@legalplace/models-v3-types";
|
|
3
3
|
import type { StateType } from "./types/State.type";
|
|
4
4
|
import type { IWizardParams } from "./types/config.type";
|
|
5
|
-
|
|
6
|
-
export interface WizardCoreProps {
|
|
7
|
-
historyType?: "browser" | "memory";
|
|
5
|
+
export interface AppNextJSProps {
|
|
8
6
|
model?: ModelV3;
|
|
9
7
|
meta?: StateType.App.Meta;
|
|
10
8
|
instance?: StateType.App.Instance;
|
|
@@ -13,15 +11,11 @@ export interface WizardCoreProps {
|
|
|
13
11
|
preloadTheme?: boolean;
|
|
14
12
|
loadPlugin: (plugin: string) => Promise<any>;
|
|
15
13
|
loadTheme: (theme: string) => Promise<any>;
|
|
16
|
-
routerAdapter?: IRouterAdapter;
|
|
17
|
-
routing?: IWizardCoreRouterProps;
|
|
18
14
|
}
|
|
19
|
-
declare class
|
|
20
|
-
|
|
21
|
-
constructor(props: WizardCoreProps);
|
|
15
|
+
declare class AppNextJS extends React.Component<AppNextJSProps> {
|
|
16
|
+
constructor(props: AppNextJSProps);
|
|
22
17
|
componentDidMount(): void;
|
|
23
18
|
componentWillUnmount(): void;
|
|
24
|
-
|
|
25
|
-
render(): import("react/jsx-runtime").JSX.Element | null;
|
|
19
|
+
render(): import("react/jsx-runtime").JSX.Element;
|
|
26
20
|
}
|
|
27
|
-
export default
|
|
21
|
+
export default AppNextJS;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import React from "react";
|
|
3
|
+
import { BrowserRouter, Route, Switch, Redirect } from "react-router-dom";
|
|
4
|
+
import { Provider } from "react-redux";
|
|
5
|
+
import { getStore, createAppStore } from "./redux/store";
|
|
6
|
+
import Globals, { setGlobals } from "./Globals";
|
|
7
|
+
import { getConfig, updateConfig } from "./config";
|
|
8
|
+
import { fetchModelPrerequisitesAction } from "./redux/actions/sagas/model";
|
|
9
|
+
import { preloadTheme } from "./helpers/preloadTheme";
|
|
10
|
+
import ViewComponent from "./components/View";
|
|
11
|
+
import PluginRoute from "./components/PluginRoute";
|
|
12
|
+
import SmartScriptComponent from "./components/SmartScript";
|
|
13
|
+
import { clearPlugins } from "./PluginLoader";
|
|
14
|
+
import { PathReader } from "./libs/PathReader";
|
|
15
|
+
import { resetStateAction } from "./redux/actions/app";
|
|
16
|
+
import { callInitDataSmartscriptAction } from "./redux";
|
|
17
|
+
import { externalPartnerRedirectUrl } from "./helpers/redirectionConfig";
|
|
18
|
+
import { autoSave } from "./helpers/autosave.helper";
|
|
19
|
+
import { NOT_FOUND_PAGE_LINK } from "./constants/links.constant";
|
|
20
|
+
const RedirectHandler = () => {
|
|
21
|
+
const matchedPartner = Object.keys(externalPartnerRedirectUrl).find((partner) => window.location.origin.toLowerCase().includes(partner));
|
|
22
|
+
if (matchedPartner) {
|
|
23
|
+
window.location.href = externalPartnerRedirectUrl[matchedPartner];
|
|
24
|
+
}
|
|
25
|
+
else {
|
|
26
|
+
window.location.href = NOT_FOUND_PAGE_LINK;
|
|
27
|
+
}
|
|
28
|
+
return _jsx(Redirect, { to: getConfig().router.notFoundPath });
|
|
29
|
+
};
|
|
30
|
+
class AppNextJS extends React.Component {
|
|
31
|
+
constructor(props) {
|
|
32
|
+
var _a;
|
|
33
|
+
super(props);
|
|
34
|
+
clearPlugins();
|
|
35
|
+
const historyType = "memory";
|
|
36
|
+
const params = Object.assign(Object.assign({}, Globals), { loadTheme: props.loadTheme, loadPlugin: props.loadPlugin });
|
|
37
|
+
if (props.model) {
|
|
38
|
+
params.model = props.model;
|
|
39
|
+
}
|
|
40
|
+
if (props.meta) {
|
|
41
|
+
params.meta = props.meta;
|
|
42
|
+
}
|
|
43
|
+
if (props.instance) {
|
|
44
|
+
params.instance = props.instance;
|
|
45
|
+
}
|
|
46
|
+
if (props.user) {
|
|
47
|
+
params.user = props.user;
|
|
48
|
+
}
|
|
49
|
+
setGlobals(params);
|
|
50
|
+
if (props.wizardParams)
|
|
51
|
+
updateConfig(props.wizardParams);
|
|
52
|
+
if (props.preloadTheme && ((_a = props.wizardParams) === null || _a === void 0 ? void 0 : _a.theme.name))
|
|
53
|
+
preloadTheme(props.wizardParams.theme.name);
|
|
54
|
+
createAppStore(historyType);
|
|
55
|
+
}
|
|
56
|
+
componentDidMount() {
|
|
57
|
+
const { dispatch, getState } = getStore();
|
|
58
|
+
const state = getState();
|
|
59
|
+
let parent = null;
|
|
60
|
+
window.addEventListener("message", ({ data, source }) => {
|
|
61
|
+
if (parent === null || data.from === "BO") {
|
|
62
|
+
parent = source;
|
|
63
|
+
}
|
|
64
|
+
if (data.from && data.from === "BO") {
|
|
65
|
+
const { variables } = data;
|
|
66
|
+
autoSave(variables, getStore());
|
|
67
|
+
}
|
|
68
|
+
});
|
|
69
|
+
dispatch(callInitDataSmartscriptAction());
|
|
70
|
+
if (!PathReader.isSmartScriptPath()) {
|
|
71
|
+
dispatch(fetchModelPrerequisitesAction(getConfig().permalink || state.app.meta.permalink, getConfig().prefix || state.app.meta.prefix || ""));
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
componentWillUnmount() {
|
|
75
|
+
getStore().dispatch(resetStateAction());
|
|
76
|
+
}
|
|
77
|
+
render() {
|
|
78
|
+
return (_jsx(Provider, { store: getStore(), children: _jsx(BrowserRouter, { children: _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 }))] }) }) }));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
export default AppNextJS;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export { default as App } from "./App";
|
|
2
2
|
export * from "./App";
|
|
3
|
-
export { default as
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./routing";
|
|
3
|
+
export { default as AppNextJS } from "./AppNextJS";
|
|
4
|
+
export * from "./AppNextJS";
|
|
6
5
|
export * from "./config";
|
|
7
6
|
export * from "./Globals";
|
|
8
7
|
export * from "./PluginLoader";
|
package/dist/index.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
export { default as App } from "./App";
|
|
2
2
|
export * from "./App";
|
|
3
|
-
export { default as
|
|
4
|
-
export * from "./
|
|
5
|
-
export * from "./routing";
|
|
3
|
+
export { default as AppNextJS } from "./AppNextJS";
|
|
4
|
+
export * from "./AppNextJS";
|
|
6
5
|
export * from "./config";
|
|
7
6
|
export * from "./Globals";
|
|
8
7
|
export * from "./PluginLoader";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legalplace/wizardx-core",
|
|
3
|
-
"version": "4.42.10-nightly.
|
|
3
|
+
"version": "4.42.10-nightly.20251126115357",
|
|
4
4
|
"author": "Moncef Hammou (moncef@legalplace.fr)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -23,17 +23,11 @@
|
|
|
23
23
|
"require": "./dist/App.js",
|
|
24
24
|
"default": "./dist/App.js"
|
|
25
25
|
},
|
|
26
|
-
"./
|
|
27
|
-
"types": "./dist/
|
|
28
|
-
"import": "./dist/
|
|
29
|
-
"require": "./dist/
|
|
30
|
-
"default": "./dist/
|
|
31
|
-
},
|
|
32
|
-
"./routing": {
|
|
33
|
-
"types": "./dist/routing/index.d.ts",
|
|
34
|
-
"import": "./dist/routing/index.js",
|
|
35
|
-
"require": "./dist/routing/index.js",
|
|
36
|
-
"default": "./dist/routing/index.js"
|
|
26
|
+
"./AppNextJS": {
|
|
27
|
+
"types": "./dist/AppNextJS.d.ts",
|
|
28
|
+
"import": "./dist/AppNextJS.js",
|
|
29
|
+
"require": "./dist/AppNextJS.js",
|
|
30
|
+
"default": "./dist/AppNextJS.js"
|
|
37
31
|
},
|
|
38
32
|
"./package.json": "./package.json"
|
|
39
33
|
},
|
package/dist/WizardCore.js
DELETED
|
@@ -1,149 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import React from "react";
|
|
3
|
-
import { Provider } from "react-redux";
|
|
4
|
-
import { getStore, createAppStore } from "./redux/store";
|
|
5
|
-
import Globals, { setGlobals } from "./Globals";
|
|
6
|
-
import { getConfig, updateConfig } from "./config";
|
|
7
|
-
import { fetchModelPrerequisitesAction } from "./redux/actions/sagas/model";
|
|
8
|
-
import { preloadTheme } from "./helpers/preloadTheme";
|
|
9
|
-
import ViewComponent from "./components/View";
|
|
10
|
-
import PluginRoute from "./components/PluginRoute";
|
|
11
|
-
import SmartScriptComponent from "./components/SmartScript";
|
|
12
|
-
import { clearPlugins } from "./PluginLoader";
|
|
13
|
-
import { PathReader } from "./libs/PathReader";
|
|
14
|
-
import { resetStateAction } from "./redux/actions/app";
|
|
15
|
-
import { callInitDataSmartscriptAction } from "./redux";
|
|
16
|
-
import { externalPartnerRedirectUrl } from "./helpers/redirectionConfig";
|
|
17
|
-
import { autoSave } from "./helpers/autosave.helper";
|
|
18
|
-
import { NOT_FOUND_PAGE_LINK } from "./constants/links.constant";
|
|
19
|
-
import { RouterProvider } from "./routing/context";
|
|
20
|
-
const getRouteComponent = (pathname, params) => {
|
|
21
|
-
if (pathname.startsWith("/p/")) {
|
|
22
|
-
const pluginPath = params.path || pathname.replace("/p/", "");
|
|
23
|
-
return {
|
|
24
|
-
component: PluginRoute,
|
|
25
|
-
props: { match: { params: { path: pluginPath } } },
|
|
26
|
-
};
|
|
27
|
-
}
|
|
28
|
-
if (pathname.includes("/smartscript/")) {
|
|
29
|
-
return { component: SmartScriptComponent };
|
|
30
|
-
}
|
|
31
|
-
const wizardInstanceRegex = /\/contrats\/.*\/continuer\//;
|
|
32
|
-
const wizardRegex = /\/contrats\/.*\/creer\//;
|
|
33
|
-
if (wizardInstanceRegex.test(pathname) || wizardRegex.test(pathname)) {
|
|
34
|
-
return { component: ViewComponent };
|
|
35
|
-
}
|
|
36
|
-
return null;
|
|
37
|
-
};
|
|
38
|
-
const RedirectHandler = ({ navigate, }) => {
|
|
39
|
-
React.useEffect(() => {
|
|
40
|
-
const matchedPartner = Object.keys(externalPartnerRedirectUrl).find((partner) => window.location.origin.toLowerCase().includes(partner));
|
|
41
|
-
if (matchedPartner) {
|
|
42
|
-
navigate === null || navigate === void 0 ? void 0 : navigate(externalPartnerRedirectUrl[matchedPartner]);
|
|
43
|
-
}
|
|
44
|
-
else {
|
|
45
|
-
navigate === null || navigate === void 0 ? void 0 : navigate(NOT_FOUND_PAGE_LINK);
|
|
46
|
-
}
|
|
47
|
-
}, [navigate]);
|
|
48
|
-
return null;
|
|
49
|
-
};
|
|
50
|
-
class WizardCore extends React.Component {
|
|
51
|
-
constructor(props) {
|
|
52
|
-
super(props);
|
|
53
|
-
this.storeInitialized = false;
|
|
54
|
-
this.initializeStore(props);
|
|
55
|
-
}
|
|
56
|
-
componentDidMount() {
|
|
57
|
-
if (!this.storeInitialized) {
|
|
58
|
-
this.initializeStore(this.props);
|
|
59
|
-
}
|
|
60
|
-
setTimeout(() => {
|
|
61
|
-
try {
|
|
62
|
-
const { dispatch, getState } = getStore();
|
|
63
|
-
const state = getState();
|
|
64
|
-
let parent = null;
|
|
65
|
-
window.addEventListener("message", ({ data, source }) => {
|
|
66
|
-
if (parent === null || data.from === "BO") {
|
|
67
|
-
parent = source;
|
|
68
|
-
}
|
|
69
|
-
if (data.from && data.from === "BO") {
|
|
70
|
-
const { variables } = data;
|
|
71
|
-
autoSave(variables, getStore());
|
|
72
|
-
}
|
|
73
|
-
});
|
|
74
|
-
dispatch(callInitDataSmartscriptAction());
|
|
75
|
-
if (!PathReader.isSmartScriptPath()) {
|
|
76
|
-
dispatch(fetchModelPrerequisitesAction(getConfig().permalink || state.app.meta.permalink, getConfig().prefix || state.app.meta.prefix || ""));
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
catch (error) {
|
|
80
|
-
console.error("Error during component mount:", error);
|
|
81
|
-
}
|
|
82
|
-
}, 0);
|
|
83
|
-
}
|
|
84
|
-
componentWillUnmount() {
|
|
85
|
-
getStore().dispatch(resetStateAction());
|
|
86
|
-
}
|
|
87
|
-
initializeStore(props) {
|
|
88
|
-
var _a;
|
|
89
|
-
if (this.storeInitialized)
|
|
90
|
-
return;
|
|
91
|
-
clearPlugins();
|
|
92
|
-
const historyType = typeof props.historyType === "string" ? props.historyType : "browser";
|
|
93
|
-
const params = Object.assign(Object.assign({}, Globals), { loadTheme: props.loadTheme, loadPlugin: props.loadPlugin });
|
|
94
|
-
if (props.model) {
|
|
95
|
-
params.model = props.model;
|
|
96
|
-
}
|
|
97
|
-
if (props.meta) {
|
|
98
|
-
params.meta = props.meta;
|
|
99
|
-
}
|
|
100
|
-
if (props.instance) {
|
|
101
|
-
params.instance = props.instance;
|
|
102
|
-
}
|
|
103
|
-
if (props.user) {
|
|
104
|
-
params.user = props.user;
|
|
105
|
-
}
|
|
106
|
-
setGlobals(params);
|
|
107
|
-
if (props.wizardParams)
|
|
108
|
-
updateConfig(props.wizardParams);
|
|
109
|
-
if (props.preloadTheme && ((_a = props.wizardParams) === null || _a === void 0 ? void 0 : _a.theme.name))
|
|
110
|
-
preloadTheme(props.wizardParams.theme.name);
|
|
111
|
-
try {
|
|
112
|
-
createAppStore(historyType);
|
|
113
|
-
console.log("Store initialized");
|
|
114
|
-
this.storeInitialized = true;
|
|
115
|
-
}
|
|
116
|
-
catch (error) {
|
|
117
|
-
console.error("Failed to initialize store:", error);
|
|
118
|
-
}
|
|
119
|
-
}
|
|
120
|
-
render() {
|
|
121
|
-
if (!this.storeInitialized) {
|
|
122
|
-
return null;
|
|
123
|
-
}
|
|
124
|
-
const { routerAdapter, routing } = this.props;
|
|
125
|
-
try {
|
|
126
|
-
const store = getStore();
|
|
127
|
-
if (routing) {
|
|
128
|
-
const { pathname, params, navigate } = routing;
|
|
129
|
-
const routeMatch = getRouteComponent(pathname, params);
|
|
130
|
-
if (routeMatch) {
|
|
131
|
-
const RouteComponent = routeMatch.component;
|
|
132
|
-
return (_jsx(Provider, { store: store, children: _jsx(RouteComponent, Object.assign({}, (routeMatch.props || {}))) }));
|
|
133
|
-
}
|
|
134
|
-
return (_jsx(Provider, { store: store, children: _jsx(RedirectHandler, { navigate: navigate }) }));
|
|
135
|
-
}
|
|
136
|
-
if (routerAdapter) {
|
|
137
|
-
return (_jsx(Provider, { store: store, children: _jsx(RouterProvider, { adapter: routerAdapter, children: _jsx(WizardCoreContent, {}) }) }));
|
|
138
|
-
}
|
|
139
|
-
console.warn("WizardCore: No routing mechanism provided. Pass either 'routerAdapter' or 'routing' props.");
|
|
140
|
-
return (_jsx(Provider, { store: store, children: _jsx("div", { children: "No routing configured" }) }));
|
|
141
|
-
}
|
|
142
|
-
catch (error) {
|
|
143
|
-
console.error("Error rendering WizardCore:", error);
|
|
144
|
-
return _jsx("div", { children: "Error initializing wizard. Check console for details." });
|
|
145
|
-
}
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
const WizardCoreContent = () => (_jsx(ViewComponent, {}));
|
|
149
|
-
export default WizardCore;
|
|
@@ -1,3 +0,0 @@
|
|
|
1
|
-
import type { IRouterAdapter } from "../types";
|
|
2
|
-
export declare const createNextJSAdapter: (router: any, pathname: string, searchParams: URLSearchParams | null, params: Record<string, string | string[]>) => IRouterAdapter;
|
|
3
|
-
export declare const useNextJSAdapter: () => IRouterAdapter;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
var __rest = (this && this.__rest) || function (s, e) {
|
|
2
|
-
var t = {};
|
|
3
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
4
|
-
t[p] = s[p];
|
|
5
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
6
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
7
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
8
|
-
t[p[i]] = s[p[i]];
|
|
9
|
-
}
|
|
10
|
-
return t;
|
|
11
|
-
};
|
|
12
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
-
import { useMemo } from "react";
|
|
14
|
-
export const createNextJSAdapter = (router, pathname, searchParams, params) => {
|
|
15
|
-
const normalizedParams = useMemo(() => {
|
|
16
|
-
const normalized = {};
|
|
17
|
-
Object.entries(params).forEach(([key, value]) => {
|
|
18
|
-
normalized[key] = Array.isArray(value) ? value[0] : value;
|
|
19
|
-
});
|
|
20
|
-
return normalized;
|
|
21
|
-
}, [params]);
|
|
22
|
-
return {
|
|
23
|
-
useParams: () => normalizedParams,
|
|
24
|
-
useNavigate: () => (path) => {
|
|
25
|
-
if (router === null || router === void 0 ? void 0 : router.push) {
|
|
26
|
-
router.push(path);
|
|
27
|
-
}
|
|
28
|
-
},
|
|
29
|
-
useLocation: () => ({
|
|
30
|
-
pathname,
|
|
31
|
-
search: searchParams ? `?${searchParams.toString()}` : "",
|
|
32
|
-
}),
|
|
33
|
-
Link: (_a) => {
|
|
34
|
-
var { to, children } = _a, props = __rest(_a, ["to", "children"]);
|
|
35
|
-
return (_jsx("a", Object.assign({ href: to, onClick: (e) => {
|
|
36
|
-
e.preventDefault();
|
|
37
|
-
if (router === null || router === void 0 ? void 0 : router.push) {
|
|
38
|
-
router.push(to);
|
|
39
|
-
}
|
|
40
|
-
} }, props, { children: children })));
|
|
41
|
-
},
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
export const useNextJSAdapter = () => {
|
|
45
|
-
const params = {};
|
|
46
|
-
const pathname = "";
|
|
47
|
-
return {
|
|
48
|
-
useParams: () => params,
|
|
49
|
-
useNavigate: () => (path) => {
|
|
50
|
-
console.warn("useNextJSAdapter: Navigation not available. Use createNextJSAdapter with Next.js router instead.");
|
|
51
|
-
},
|
|
52
|
-
useLocation: () => ({
|
|
53
|
-
pathname,
|
|
54
|
-
search: "",
|
|
55
|
-
}),
|
|
56
|
-
Link: (_a) => {
|
|
57
|
-
var { to, children } = _a, props = __rest(_a, ["to", "children"]);
|
|
58
|
-
return (_jsx("a", Object.assign({ href: to }, props, { children: children })));
|
|
59
|
-
},
|
|
60
|
-
};
|
|
61
|
-
};
|
|
@@ -1,16 +0,0 @@
|
|
|
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
|
-
});
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import type { IRouterAdapter } from "./types";
|
|
3
|
-
export interface RouterProviderProps {
|
|
4
|
-
adapter: IRouterAdapter;
|
|
5
|
-
children: React.ReactNode;
|
|
6
|
-
}
|
|
7
|
-
export declare const RouterProvider: React.FC<RouterProviderProps>;
|
|
8
|
-
export declare const useRouterAdapter: () => IRouterAdapter;
|
|
9
|
-
export declare const useParams: <T = any>() => T;
|
|
10
|
-
export declare const useNavigate: () => (path: string) => void;
|
|
11
|
-
export declare const useLocation: () => {
|
|
12
|
-
pathname: string;
|
|
13
|
-
search: string;
|
|
14
|
-
};
|
package/dist/routing/context.js
DELETED
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { createContext, useContext } from "react";
|
|
3
|
-
const RouterContext = createContext(null);
|
|
4
|
-
export const RouterProvider = ({ adapter, children, }) => (_jsx(RouterContext.Provider, { value: adapter, children: children }));
|
|
5
|
-
export const useRouterAdapter = () => {
|
|
6
|
-
const adapter = useContext(RouterContext);
|
|
7
|
-
if (!adapter) {
|
|
8
|
-
throw new Error("useRouterAdapter must be used within a RouterProvider or use native react-router hooks directly");
|
|
9
|
-
}
|
|
10
|
-
return adapter;
|
|
11
|
-
};
|
|
12
|
-
export const useParams = () => {
|
|
13
|
-
const adapter = useRouterAdapter();
|
|
14
|
-
return adapter.useParams();
|
|
15
|
-
};
|
|
16
|
-
export const useNavigate = () => {
|
|
17
|
-
const adapter = useRouterAdapter();
|
|
18
|
-
return adapter.useNavigate();
|
|
19
|
-
};
|
|
20
|
-
export const useLocation = () => {
|
|
21
|
-
const adapter = useRouterAdapter();
|
|
22
|
-
return adapter.useLocation();
|
|
23
|
-
};
|
package/dist/routing/index.d.ts
DELETED
package/dist/routing/index.js
DELETED
package/dist/routing/types.d.ts
DELETED
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
import type { ReactNode, ComponentType } from "react";
|
|
2
|
-
export interface IRouterAdapter {
|
|
3
|
-
useParams: <T = any>() => T;
|
|
4
|
-
useNavigate: () => (path: string) => void;
|
|
5
|
-
useLocation: () => {
|
|
6
|
-
pathname: string;
|
|
7
|
-
search: string;
|
|
8
|
-
};
|
|
9
|
-
Link: ComponentType<{
|
|
10
|
-
to: string;
|
|
11
|
-
children: ReactNode;
|
|
12
|
-
[key: string]: any;
|
|
13
|
-
}>;
|
|
14
|
-
}
|
|
15
|
-
export interface IRouteConfig {
|
|
16
|
-
path: string;
|
|
17
|
-
component: ComponentType<any>;
|
|
18
|
-
exact?: boolean;
|
|
19
|
-
strict?: boolean;
|
|
20
|
-
}
|
|
21
|
-
export interface IWizardCoreRouterProps {
|
|
22
|
-
pathname: string;
|
|
23
|
-
search?: string;
|
|
24
|
-
params: Record<string, string | undefined>;
|
|
25
|
-
navigate: (path: string) => void;
|
|
26
|
-
}
|
package/dist/routing/types.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
package/dist/wizardcore.entry.js
DELETED