@legalplace/wizardx-core 4.42.10-nightly.20251125120616 → 4.42.10-nightly.20251125140433

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.
@@ -16,14 +16,12 @@ export interface WizardCoreProps {
16
16
  routerAdapter?: IRouterAdapter;
17
17
  routing?: IWizardCoreRouterProps;
18
18
  }
19
- declare class WizardCore extends React.Component<WizardCoreProps, {
20
- initialized: boolean;
21
- }> {
19
+ declare class WizardCore extends React.Component<WizardCoreProps> {
22
20
  private storeInitialized;
23
21
  constructor(props: WizardCoreProps);
24
- private initializeStore;
25
22
  componentDidMount(): void;
26
23
  componentWillUnmount(): void;
24
+ private initializeStore;
27
25
  render(): import("react/jsx-runtime").JSX.Element | null;
28
26
  }
29
27
  export default WizardCore;
@@ -18,7 +18,6 @@ import { autoSave } from "./helpers/autosave.helper";
18
18
  import { NOT_FOUND_PAGE_LINK } from "./constants/links.constant";
19
19
  import { RouterProvider } from "./routing/context";
20
20
  const getRouteComponent = (pathname, params) => {
21
- const config = getConfig();
22
21
  if (pathname.startsWith("/p/")) {
23
22
  const pluginPath = params.path || pathname.replace("/p/", "");
24
23
  return {
@@ -40,23 +39,51 @@ const RedirectHandler = ({ navigate, }) => {
40
39
  React.useEffect(() => {
41
40
  const matchedPartner = Object.keys(externalPartnerRedirectUrl).find((partner) => window.location.origin.toLowerCase().includes(partner));
42
41
  if (matchedPartner) {
43
- window.location.href = externalPartnerRedirectUrl[matchedPartner];
42
+ navigate === null || navigate === void 0 ? void 0 : navigate(externalPartnerRedirectUrl[matchedPartner]);
44
43
  }
45
44
  else {
46
- window.location.href = NOT_FOUND_PAGE_LINK;
45
+ navigate === null || navigate === void 0 ? void 0 : navigate(NOT_FOUND_PAGE_LINK);
47
46
  }
48
- }, []);
47
+ }, [navigate]);
49
48
  return null;
50
49
  };
51
50
  class WizardCore extends React.Component {
52
51
  constructor(props) {
53
52
  super(props);
54
53
  this.storeInitialized = false;
55
- this.state = {
56
- initialized: false,
57
- };
58
54
  this.initializeStore(props);
59
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
+ }
60
87
  initializeStore(props) {
61
88
  var _a;
62
89
  if (this.storeInitialized)
@@ -83,44 +110,13 @@ class WizardCore extends React.Component {
83
110
  preloadTheme(props.wizardParams.theme.name);
84
111
  try {
85
112
  createAppStore(historyType);
113
+ console.log("Store initialized");
86
114
  this.storeInitialized = true;
87
115
  }
88
116
  catch (error) {
89
117
  console.error("Failed to initialize store:", error);
90
118
  }
91
119
  }
92
- componentDidMount() {
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 });
115
- }
116
- catch (error) {
117
- console.error("Error during component mount:", error);
118
- }
119
- }, 0);
120
- }
121
- componentWillUnmount() {
122
- getStore().dispatch(resetStateAction());
123
- }
124
120
  render() {
125
121
  if (!this.storeInitialized) {
126
122
  return null;
@@ -39,8 +39,7 @@ class ViewComponent extends React.Component {
39
39
  break;
40
40
  default:
41
41
  if (false)
42
- AppStateComponent =
43
- loadThemeComponent("WizardComponent");
42
+ AppStateComponent = loadThemeComponent("WizardComponent");
44
43
  else
45
44
  AppStateComponent = () => _jsx(_Fragment, {});
46
45
  break;
@@ -18,6 +18,7 @@ import { updateOptionAction, updateVariableAction } from "../actions/inputs";
18
18
  import { smartScriptLoadedMessage } from "../../constants/smartscript";
19
19
  import { RESET_STATE } from "../constants/app";
20
20
  let iframe = null;
21
+ let iframeStyleObserver = null;
21
22
  const watchEnableSmartScript = (mpi, next, action) => {
22
23
  next(action);
23
24
  if (PathReader.isSmartScriptPath()) {
@@ -27,9 +28,38 @@ const watchEnableSmartScript = (mpi, next, action) => {
27
28
  if (iframeElement) {
28
29
  iframeElement.remove();
29
30
  }
31
+ if (iframeStyleObserver) {
32
+ iframeStyleObserver.disconnect();
33
+ iframeStyleObserver = null;
34
+ }
30
35
  iframe = document.createElement("iframe");
31
36
  iframe.id = "lp-smartscript";
32
- iframe.setAttribute("style", "position: absolute; width:0; height:0; border:0;");
37
+ const correctStyles = {
38
+ position: "absolute",
39
+ width: "0",
40
+ height: "0",
41
+ border: "0",
42
+ left: "-9999px",
43
+ top: "-9999px",
44
+ visibility: "hidden",
45
+ pointerEvents: "none",
46
+ zIndex: "-1",
47
+ };
48
+ Object.assign(iframe.style, correctStyles);
49
+ iframeStyleObserver = new MutationObserver((mutations) => {
50
+ mutations.forEach((mutation) => {
51
+ if (mutation.type === "attributes" &&
52
+ mutation.attributeName === "style") {
53
+ if (iframe) {
54
+ Object.assign(iframe.style, correctStyles);
55
+ }
56
+ }
57
+ });
58
+ });
59
+ iframeStyleObserver.observe(iframe, {
60
+ attributes: true,
61
+ attributeFilter: ["style"],
62
+ });
33
63
  const state = mpi.getState();
34
64
  const permalink = getConfig().permalink || state.app.meta.permalink || "";
35
65
  const prefix = getConfig().prefix || state.app.meta.prefix || "";
@@ -64,6 +94,10 @@ const watchEnableSmartScript = (mpi, next, action) => {
64
94
  };
65
95
  const watchResetState = (mpi, next, action) => {
66
96
  next(action);
97
+ if (iframeStyleObserver) {
98
+ iframeStyleObserver.disconnect();
99
+ iframeStyleObserver = null;
100
+ }
67
101
  if (iframe) {
68
102
  document.body.removeChild(iframe);
69
103
  iframe = null;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legalplace/wizardx-core",
3
- "version": "4.42.10-nightly.20251125120616",
3
+ "version": "4.42.10-nightly.20251125140433",
4
4
  "author": "Moncef Hammou (moncef@legalplace.fr)",
5
5
  "license": "MIT",
6
6
  "files": [