@legalplace/wizardx-core 4.42.10-nightly.20251126105226 → 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 CHANGED
@@ -43,12 +43,11 @@ root.render(
43
43
  ```tsx
44
44
  // app/wizard/page.tsx
45
45
  'use client';
46
- import { App } from "@legalplace/wizardx-core";
46
+ import { AppNextJS } from "@legalplace/wizardx-core";
47
47
 
48
48
  export default function WizardPage() {
49
49
  return (
50
- <App
51
- historyType="browser"
50
+ <AppNextJS
52
51
  loadPlugin={loadPlugin}
53
52
  loadTheme={loadTheme}
54
53
  wizardParams={wizardParams}
@@ -57,6 +56,8 @@ export default function WizardPage() {
57
56
  }
58
57
  ```
59
58
 
59
+ **Important**: Use `AppNextJS` instead of `App` for Next.js projects.
60
+
60
61
  See [NEXTJS-INTEGRATION.md](./NEXTJS-INTEGRATION.md) for complete Next.js setup including URL rewrites.
61
62
 
62
63
  ## 📚 Documentation
@@ -70,7 +71,7 @@ See [NEXTJS-INTEGRATION.md](./NEXTJS-INTEGRATION.md) for complete Next.js setup
70
71
  ### Components
71
72
 
72
73
  #### `App` Component
73
- The main component that uses React Router for client-side routing.
74
+ The main component for Create React App that uses React Router with ConnectedRouter.
74
75
 
75
76
  ```tsx
76
77
  import { App } from "@legalplace/wizardx-core";
@@ -85,6 +86,21 @@ import { App } from "@legalplace/wizardx-core";
85
86
  />
86
87
  ```
87
88
 
89
+ #### `AppNextJS` Component
90
+ Optimized component for Next.js that uses BrowserRouter instead of ConnectedRouter.
91
+
92
+ ```tsx
93
+ import { AppNextJS } from "@legalplace/wizardx-core";
94
+
95
+ <AppNextJS
96
+ loadPlugin={loadPlugin}
97
+ loadTheme={loadTheme}
98
+ wizardParams={wizardParams}
99
+ model={initialModel}
100
+ user={user}
101
+ />
102
+ ```
103
+
88
104
  ### Themes
89
105
 
90
106
  Themes control the visual appearance of the wizard. Load themes dynamically:
@@ -152,7 +168,8 @@ const wizardParams = {
152
168
 
153
169
  ```typescript
154
170
  // Components
155
- export { App } from "@legalplace/wizardx-core";
171
+ export { App } from "@legalplace/wizardx-core"; // For CRA
172
+ export { AppNextJS } from "@legalplace/wizardx-core"; // For Next.js
156
173
 
157
174
  // Configuration
158
175
  export { getConfig, updateConfig } from "@legalplace/wizardx-core";
@@ -0,0 +1,21 @@
1
+ import React from "react";
2
+ import type { ModelV3 } from "@legalplace/models-v3-types";
3
+ import type { StateType } from "./types/State.type";
4
+ import type { IWizardParams } from "./types/config.type";
5
+ export interface AppNextJSProps {
6
+ model?: ModelV3;
7
+ meta?: StateType.App.Meta;
8
+ instance?: StateType.App.Instance;
9
+ user?: StateType.User;
10
+ wizardParams?: IWizardParams;
11
+ preloadTheme?: boolean;
12
+ loadPlugin: (plugin: string) => Promise<any>;
13
+ loadTheme: (theme: string) => Promise<any>;
14
+ }
15
+ declare class AppNextJS extends React.Component<AppNextJSProps> {
16
+ constructor(props: AppNextJSProps);
17
+ componentDidMount(): void;
18
+ componentWillUnmount(): void;
19
+ render(): import("react/jsx-runtime").JSX.Element;
20
+ }
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,5 +1,7 @@
1
1
  export { default as App } from "./App";
2
2
  export * from "./App";
3
+ export { default as AppNextJS } from "./AppNextJS";
4
+ export * from "./AppNextJS";
3
5
  export * from "./config";
4
6
  export * from "./Globals";
5
7
  export * from "./PluginLoader";
package/dist/index.js CHANGED
@@ -1,5 +1,7 @@
1
1
  export { default as App } from "./App";
2
2
  export * from "./App";
3
+ export { default as AppNextJS } from "./AppNextJS";
4
+ export * from "./AppNextJS";
3
5
  export * from "./config";
4
6
  export * from "./Globals";
5
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.20251126105226",
3
+ "version": "4.42.10-nightly.20251126115357",
4
4
  "author": "Moncef Hammou (moncef@legalplace.fr)",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -23,6 +23,12 @@
23
23
  "require": "./dist/App.js",
24
24
  "default": "./dist/App.js"
25
25
  },
26
+ "./AppNextJS": {
27
+ "types": "./dist/AppNextJS.d.ts",
28
+ "import": "./dist/AppNextJS.js",
29
+ "require": "./dist/AppNextJS.js",
30
+ "default": "./dist/AppNextJS.js"
31
+ },
26
32
  "./package.json": "./package.json"
27
33
  },
28
34
  "scripts": {