@legalplace/wizardx-core 2.1.0-alpha.0 → 2.1.0-alpha.1
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/CHANGELOG.md +11 -0
- package/dist/App.d.ts +1 -0
- package/dist/App.js +4 -0
- package/dist/helpers/preloadTheme.d.ts +1 -0
- package/dist/helpers/preloadTheme.js +19 -0
- package/package.json +2 -2
- package/src/App.tsx +6 -0
- package/src/helpers/preloadTheme.ts +17 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,17 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [2.1.0-alpha.1](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.1.0-alpha.0...@legalplace/wizardx-core@2.1.0-alpha.1) (2021-11-03)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Features
|
|
10
|
+
|
|
11
|
+
* supporting theme preloading for wizardx-core & preloading theme on kanoon-app api[#4363](https://git.legalplace.eu/legalplace/monorepo/issues/4363) ([01f258e](https://git.legalplace.eu/legalplace/monorepo/commits/01f258e4e2266ae6a8978fa4035289b50e0366bc))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
6
17
|
# [2.1.0-alpha.0](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.0.0...@legalplace/wizardx-core@2.1.0-alpha.0) (2021-11-03)
|
|
7
18
|
|
|
8
19
|
|
package/dist/App.d.ts
CHANGED
package/dist/App.js
CHANGED
|
@@ -11,8 +11,10 @@ import ViewComponent from './components/View';
|
|
|
11
11
|
import SmartScriptComponent from './components/SmartScript';
|
|
12
12
|
import { PluginRoute } from './components/PluginRoute';
|
|
13
13
|
import { clearPlugins } from './PluginLoader';
|
|
14
|
+
import { preloadTheme } from './helpers/preloadTheme';
|
|
14
15
|
class WizardXCore extends React.Component {
|
|
15
16
|
constructor(props) {
|
|
17
|
+
var _a;
|
|
16
18
|
super(props);
|
|
17
19
|
clearPlugins();
|
|
18
20
|
const historyType = typeof props.historyType === 'string' ? props.historyType : 'browser';
|
|
@@ -39,6 +41,8 @@ class WizardXCore extends React.Component {
|
|
|
39
41
|
setGlobals(params);
|
|
40
42
|
if (props.wizardParams)
|
|
41
43
|
updateConfig(props.wizardParams);
|
|
44
|
+
if (props.preloadTheme && ((_a = props.wizardParams) === null || _a === void 0 ? void 0 : _a.theme.name))
|
|
45
|
+
preloadTheme(props.wizardParams.theme.name);
|
|
42
46
|
createAppStore(historyType);
|
|
43
47
|
}
|
|
44
48
|
componentDidMount() {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const preloadTheme: (theme: string) => Promise<void>;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
+
});
|
|
9
|
+
};
|
|
10
|
+
import Globals from '../Globals';
|
|
11
|
+
export const preloadTheme = (theme) => __awaiter(void 0, void 0, void 0, function* () {
|
|
12
|
+
const { default: components } = (yield Globals.loadTheme(theme));
|
|
13
|
+
try {
|
|
14
|
+
components.WizardComponent.preload();
|
|
15
|
+
components.TermsheetComponent.preload();
|
|
16
|
+
components.EmailComponent.preload();
|
|
17
|
+
}
|
|
18
|
+
catch (e) { }
|
|
19
|
+
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legalplace/wizardx-core",
|
|
3
|
-
"version": "2.1.0-alpha.
|
|
3
|
+
"version": "2.1.0-alpha.1",
|
|
4
4
|
"author": "Moncef Hammou (moncef@legalplace.fr)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -82,5 +82,5 @@
|
|
|
82
82
|
"*.test.ts",
|
|
83
83
|
"*.test.tsx"
|
|
84
84
|
],
|
|
85
|
-
"gitHead": "
|
|
85
|
+
"gitHead": "fe3a24469f1ca2e1870f74c5b84f728bf677b437"
|
|
86
86
|
}
|
package/src/App.tsx
CHANGED
|
@@ -14,6 +14,7 @@ import SmartScriptComponent from './components/SmartScript';
|
|
|
14
14
|
import { PluginRoute } from './components/PluginRoute';
|
|
15
15
|
import { clearPlugins } from './PluginLoader';
|
|
16
16
|
import { IWizardParams } from './types/config.type';
|
|
17
|
+
import { preloadTheme } from './helpers/preloadTheme';
|
|
17
18
|
|
|
18
19
|
// App components props interface
|
|
19
20
|
export interface AppProps {
|
|
@@ -23,6 +24,7 @@ export interface AppProps {
|
|
|
23
24
|
instance?: StateType.App.Instance;
|
|
24
25
|
user?: StateType.User;
|
|
25
26
|
wizardParams?: IWizardParams;
|
|
27
|
+
preloadTheme?: boolean;
|
|
26
28
|
loadPlugin: (plugin: string) => Promise<any>;
|
|
27
29
|
loadTheme: (theme: string) => Promise<any>;
|
|
28
30
|
}
|
|
@@ -73,6 +75,10 @@ class WizardXCore extends React.Component<AppProps, { loaded: boolean }> {
|
|
|
73
75
|
// Setting Wizard params
|
|
74
76
|
if (props.wizardParams) updateConfig(props.wizardParams);
|
|
75
77
|
|
|
78
|
+
// Preloading theme
|
|
79
|
+
if (props.preloadTheme && props.wizardParams?.theme.name)
|
|
80
|
+
preloadTheme(props.wizardParams.theme.name);
|
|
81
|
+
|
|
76
82
|
// Creating the store
|
|
77
83
|
createAppStore(historyType);
|
|
78
84
|
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { LoadableComponent } from '@loadable/component';
|
|
2
|
+
import Globals from '../Globals';
|
|
3
|
+
|
|
4
|
+
export const preloadTheme = async (theme: string) => {
|
|
5
|
+
// Preloading theme
|
|
6
|
+
const { default: components } = (await Globals.loadTheme(theme)) as {
|
|
7
|
+
default: Record<string, LoadableComponent<React.ComponentType>>;
|
|
8
|
+
};
|
|
9
|
+
|
|
10
|
+
// Preloading components
|
|
11
|
+
try {
|
|
12
|
+
components.WizardComponent.preload();
|
|
13
|
+
components.TermsheetComponent.preload();
|
|
14
|
+
components.EmailComponent.preload();
|
|
15
|
+
// eslint-disable-next-line no-empty
|
|
16
|
+
} catch (e) {}
|
|
17
|
+
};
|