@legalplace/wizardx-core 2.7.0 → 2.7.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 +14 -0
- package/dist/components/SmartScript.d.ts +2 -2
- package/dist/components/SmartScript.js +2 -0
- package/dist/componentsConnectors/connector/componentConnector.js +15 -16
- package/dist/helpers/propsEqualityCheck.js +9 -8
- package/dist/redux/selectors/app.js +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,20 @@
|
|
|
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.7.1](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.7.0...@legalplace/wizardx-core@2.7.1) (2022-01-18)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* fix cacheKey for memoized states api[#4719](https://git.legalplace.eu/legalplace/monorepo/issues/4719) ([b76f9a0](https://git.legalplace.eu/legalplace/monorepo/commits/b76f9a0cbee082ff607da40682a40253c9991eec))
|
|
12
|
+
* fix input type number and enabling bundle analyzer with variable only api[#4719](https://git.legalplace.eu/legalplace/monorepo/issues/4719) ([3948d0b](https://git.legalplace.eu/legalplace/monorepo/commits/3948d0b520ebc2aac5f1ad735d0beb12814486f2))
|
|
13
|
+
* fix issue with props equalityCheck on state memoization api[#4719](https://git.legalplace.eu/legalplace/monorepo/issues/4719) ([e059091](https://git.legalplace.eu/legalplace/monorepo/commits/e059091be42aa358598f4bc2173fd940c7da968f))
|
|
14
|
+
* fix moment import api[#4719](https://git.legalplace.eu/legalplace/monorepo/issues/4719) ([bb4fd18](https://git.legalplace.eu/legalplace/monorepo/commits/bb4fd188666fb412e8c96cd22bc7149c5566aa55))
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
|
|
6
20
|
# [2.7.0](https://git.legalplace.eu/legalplace/monorepo/compare/@legalplace/wizardx-core@2.6.4...@legalplace/wizardx-core@2.7.0) (2022-01-06)
|
|
7
21
|
|
|
8
22
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Action } from "redux";
|
|
2
|
-
import
|
|
2
|
+
import moment from "moment-business-days";
|
|
3
3
|
import { SmartScriptStore } from "../libs/SmartScriptStore";
|
|
4
4
|
import { StateType } from "../types/State.type";
|
|
5
5
|
export declare type TInitTriggersCallback = (triggers: StateType.SmartScript["triggers"], actions: Action[]) => void;
|
|
@@ -21,7 +21,7 @@ declare global {
|
|
|
21
21
|
displayOption: typeof SmartScriptStore.displayOption;
|
|
22
22
|
hideVariable: typeof SmartScriptStore.hideVariable;
|
|
23
23
|
displayVariable: typeof SmartScriptStore.displayVariable;
|
|
24
|
-
moment:
|
|
24
|
+
moment: typeof moment;
|
|
25
25
|
triggerListeners: (type: "option" | "variable", id: number, inputs: StateType.Inputs) => Action[];
|
|
26
26
|
initTriggers: (callback: TInitTriggersCallback, inputs: StateType.Inputs, newInstance: boolean) => void;
|
|
27
27
|
}
|
|
@@ -2,6 +2,7 @@ import { Fragment as _Fragment, jsx as _jsx } from "react/jsx-runtime";
|
|
|
2
2
|
import { useEffect, useState } from "react";
|
|
3
3
|
import { useParams } from "react-router-dom";
|
|
4
4
|
import queryString from "query-string";
|
|
5
|
+
import moment from "moment-business-days";
|
|
5
6
|
import { getConfig } from "../config";
|
|
6
7
|
import { SmartScriptStore } from "../libs/SmartScriptStore";
|
|
7
8
|
const SmartScriptComponent = () => {
|
|
@@ -24,6 +25,7 @@ const SmartScriptComponent = () => {
|
|
|
24
25
|
window.displayVariable = SmartScriptStore.displayVariable;
|
|
25
26
|
window.hideOption = SmartScriptStore.hideOption;
|
|
26
27
|
window.displayOption = SmartScriptStore.displayOption;
|
|
28
|
+
window.moment = moment;
|
|
27
29
|
const apiEndpoint = getConfig().apiEndpoint + (/\/$/.test(getConfig().apiEndpoint) ? "" : "/");
|
|
28
30
|
const { permalink, uniqid } = useParams();
|
|
29
31
|
const modelVersion = queryString.parse(window.location.search).version;
|
|
@@ -40,25 +40,24 @@ const ConnectorHooc = (Component, componentName, additionnalHooks) => {
|
|
|
40
40
|
ConnectedComponent.displayName = `connectedComponent(${componentName})`;
|
|
41
41
|
return ConnectedComponent;
|
|
42
42
|
};
|
|
43
|
-
const generateCacheKey = (object) =>
|
|
44
|
-
.
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
return
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
function MemoizeStateToProps(stateToProps) {
|
|
43
|
+
const generateCacheKey = (object, hashKey = true) => {
|
|
44
|
+
const key = Object.entries(object).reduce((p, [prop, value]) => {
|
|
45
|
+
if (["function", "undefined"].includes(typeof value))
|
|
46
|
+
return `${p}.${prop}.${typeof value}`;
|
|
47
|
+
if (value === null)
|
|
48
|
+
return `${p}.${prop}.null`;
|
|
49
|
+
if (value && typeof value === "object")
|
|
50
|
+
return `${prop}.${generateCacheKey(value, false)}`;
|
|
51
|
+
return `${p}.${prop}.${value.toString()}`;
|
|
52
|
+
}, "");
|
|
53
|
+
return hashKey && key.length > 40 ? sha1(key, "hex") : key;
|
|
54
|
+
};
|
|
55
|
+
function MemoizeStateToProps(componentName, stateToProps) {
|
|
57
56
|
if (!stateToProps)
|
|
58
57
|
return undefined;
|
|
59
58
|
const cache = {};
|
|
60
59
|
return (selectors) => (state, ownProps) => {
|
|
61
|
-
const nextProps = stateToProps(
|
|
60
|
+
const nextProps = stateToProps(selectors)(state, ownProps);
|
|
62
61
|
const cacheKey = generateCacheKey(ownProps);
|
|
63
62
|
const prevProps = cache[cacheKey];
|
|
64
63
|
const equalityCheck = prevProps && propsEqualityCheck(cache[cacheKey], nextProps);
|
|
@@ -91,7 +90,7 @@ export function componentConnector(options) {
|
|
|
91
90
|
const hooc = ConnectorHooc(Component, componentName, additionnalHooks);
|
|
92
91
|
return (connectStore ? ConnectorConnectWithStore : ConnectorConnect)({
|
|
93
92
|
stateToProps: memoizeStateToProps
|
|
94
|
-
? MemoizeStateToProps(stateToProps)
|
|
93
|
+
? MemoizeStateToProps(componentName, stateToProps)
|
|
95
94
|
: stateToProps,
|
|
96
95
|
dispatchToProps,
|
|
97
96
|
})(hooc);
|
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
export const propsEqualityCheck = (prevProps, nextProps) => Object.entries(nextProps).
|
|
2
|
-
|
|
3
|
-
if (
|
|
4
|
-
|
|
1
|
+
export const propsEqualityCheck = (prevProps, nextProps) => Object.entries(nextProps).length === Object.entries(prevProps).length &&
|
|
2
|
+
Object.entries(nextProps).reduce((ps, [k, v]) => {
|
|
3
|
+
if (prevProps[k] !== v) {
|
|
4
|
+
if (typeof prevProps[k] === "object" && typeof v === "object") {
|
|
5
|
+
return ps && propsEqualityCheck(prevProps[k], v);
|
|
6
|
+
}
|
|
7
|
+
return false;
|
|
5
8
|
}
|
|
6
|
-
return
|
|
7
|
-
}
|
|
8
|
-
return ps;
|
|
9
|
-
}, true);
|
|
9
|
+
return ps;
|
|
10
|
+
}, true);
|
|
@@ -9,7 +9,7 @@ export const selectIsLastWizardPage = createSelector((state) => state.app.pagina
|
|
|
9
9
|
state.app.wizard.availableSections.length, (state) => state.app.pagination.currentPage.toString());
|
|
10
10
|
export const selectGreatestPage = createSelector((state) => state.app.pagination.greatestPage, (state) => state.app.pagination.greatestPage.toString());
|
|
11
11
|
export const selectCurrentSectionId = createSelector((state) => state.app.wizard.currentSectionId, (state) => state.app.wizard.currentSectionId.toString());
|
|
12
|
-
export const selectAvailableSections = createSelector((state) => [...state.app.wizard.availableSections], (state) => state.app.wizard.availableSections.reduce((p, c) => p
|
|
12
|
+
export const selectAvailableSections = createSelector((state) => [...state.app.wizard.availableSections], (state) => state.app.wizard.availableSections.reduce((p, c) => `${p}.${c}`, "0"));
|
|
13
13
|
export const selectAvailableOptions = createSelector((state, document = "main") => {
|
|
14
14
|
let availableOptions = [];
|
|
15
15
|
const { availableSections } = state.app.wizard;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@legalplace/wizardx-core",
|
|
3
|
-
"version": "2.7.
|
|
3
|
+
"version": "2.7.1",
|
|
4
4
|
"author": "Moncef Hammou (moncef@legalplace.fr)",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"files": [
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"@legalplace/lplogic": "^2.1.6",
|
|
25
25
|
"@legalplace/model-healthcheck": "^1.1.5",
|
|
26
26
|
"@legalplace/referencesparser": "^1.7.0",
|
|
27
|
-
"@legalplace/storybook": "2.
|
|
27
|
+
"@legalplace/storybook": "2.10.4",
|
|
28
28
|
"@loadable/component": "^5.15.0",
|
|
29
29
|
"@redux-saga/core": "^1.1.3",
|
|
30
30
|
"connected-react-router": "^6.8.0",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
"mousetrap": "^1.6.5",
|
|
36
36
|
"prop-types": "^15.7.2",
|
|
37
37
|
"query-string": "^7.0.1",
|
|
38
|
-
"react": "^17.0.
|
|
38
|
+
"react": "^17.0.2",
|
|
39
39
|
"react-app-polyfill": "^2.0.0",
|
|
40
|
-
"react-dom": "^17.0.
|
|
40
|
+
"react-dom": "^17.0.2",
|
|
41
41
|
"react-redux": "^7.2.5",
|
|
42
42
|
"react-router": "5.2.1",
|
|
43
43
|
"react-router-dom": "^5.2.0",
|
|
@@ -91,5 +91,5 @@
|
|
|
91
91
|
"*.test.ts",
|
|
92
92
|
"*.test.tsx"
|
|
93
93
|
],
|
|
94
|
-
"gitHead": "
|
|
94
|
+
"gitHead": "47024b8ba1d94f8c646b5f8f15950c6804f32159"
|
|
95
95
|
}
|