@legalplace/wizardx-core 4.36.7 → 4.36.9

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.
@@ -23,6 +23,8 @@ export declare type ConnectOptionMapProps = {
23
23
  childVariables: number[];
24
24
  isSelected?: boolean;
25
25
  parentId?: number;
26
+ isAllHiddenOptions?: boolean;
27
+ isParentMandatory?: boolean;
26
28
  };
27
29
  export declare type ConnectOptionDispatchProps = {
28
30
  updateOption: (value: boolean, id?: number, index?: number) => void;
@@ -22,14 +22,28 @@ const selectedRadioChilds = (id, index, selectors) => {
22
22
  selectors.selectOptionInputByIndex(childId, index));
23
23
  })[0];
24
24
  };
25
+ const getHiddenOptions = (parentOptions, selectors) => {
26
+ const isAllHidden = parentOptions
27
+ .map((option) => {
28
+ const { meta } = selectors.selectOptionReference(option);
29
+ return meta.hidden;
30
+ })
31
+ .filter((isHidden) => !isHidden).length;
32
+ return isAllHidden === 0;
33
+ };
25
34
  const stateToProps = (selectors) => (state, ownProps) => {
26
35
  const { id, index } = ownProps;
27
36
  const option = selectors.selectOptionReference(id);
28
37
  const [parentId] = selectors.selectOptionParents(id);
29
38
  let isSelected = false;
39
+ let isAllHiddenOptions;
40
+ let isParentMandatory;
30
41
  if (parentId) {
42
+ const { options: parentOptions, meta: metaParent } = selectors.selectOptionReference(parentId);
31
43
  const selectedRadioChild = selectedRadioChilds(parentId, index, selectors);
32
44
  isSelected = selectedRadioChild === id;
45
+ isAllHiddenOptions = getHiddenOptions(parentOptions, selectors);
46
+ isParentMandatory = metaParent.mandatory;
33
47
  }
34
48
  const display = canOptionDisplay(id, index, selectors);
35
49
  const selectedRadioChild = selectedRadioChilds(id, index, selectors);
@@ -64,6 +78,8 @@ const stateToProps = (selectors) => (state, ownProps) => {
64
78
  childVariables,
65
79
  isSelected,
66
80
  parentId,
81
+ isAllHiddenOptions,
82
+ isParentMandatory,
67
83
  };
68
84
  };
69
85
  const dispatchToProps = (actions) => (dispatch, ownProps) => ({
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legalplace/wizardx-core",
3
- "version": "4.36.7",
3
+ "version": "4.36.9",
4
4
  "author": "Moncef Hammou (moncef@legalplace.fr)",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -21,7 +21,7 @@
21
21
  "dependencies": {
22
22
  "@appnest/masonry-layout": "^2.0.8",
23
23
  "@cryptography/sha1": "^0.2.0",
24
- "@legalplace/data-gouv": "^1.6.36",
24
+ "@legalplace/data-gouv": "^1.6.37",
25
25
  "@legalplace/lp-events": "1.14.0",
26
26
  "@legalplace/lplogic": "2.3.1",
27
27
  "@legalplace/model-healthcheck": "^1.1.5",
@@ -62,7 +62,7 @@
62
62
  "@legalplace/eslint-config": "^2.3.0",
63
63
  "@legalplace/models-v3-types": "^5.13.28",
64
64
  "@legalplace/prettier-config": "^2.1.3",
65
- "@legalplace/typeorm-entities": "^5.58.2",
65
+ "@legalplace/typeorm-entities": "^5.58.3",
66
66
  "@swc-node/jest": "^1.3.2",
67
67
  "@swc/core": "^1.2.93",
68
68
  "@swc/jest": "^0.2.4",
@@ -100,5 +100,5 @@
100
100
  "*.test.ts",
101
101
  "*.test.tsx"
102
102
  ],
103
- "gitHead": "3a73ed40c27e1226ce4a842f37dfd10423df76c0"
103
+ "gitHead": "94361e9f84104b7e5601d3610266b053f0669b24"
104
104
  }