@legalplace/wizardx-core 4.13.1 → 4.13.2

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.
@@ -185,18 +185,22 @@ const watchFetchModelSucceeded = (mpi, next, action) => {
185
185
  const variableId = parseInt(variableStrId, 10);
186
186
  const { prefillings, prioritizePrefillings } = selectVariableReference(variableId);
187
187
  if (Array.isArray(prefillings)) {
188
- const firstUnconditionnedIndex = prefillings
189
- .map((c) => c.conditions === undefined ||
190
- ConditionsMapper.countConditions(c.conditions) === 0)
191
- .indexOf(true);
192
- if (firstUnconditionnedIndex > -1) {
193
- variables[variableId].forEach((value, variableIndex) => {
194
- const prefillerValue = parsePrefillerValue(variableId, variableIndex, firstUnconditionnedIndex);
195
- if (value.toString().trim().length === 0 || prioritizePrefillings) {
196
- mpi.dispatch(updateVariableAction(variableId, prefillerValue, variableIndex));
197
- }
198
- });
199
- }
188
+ variables[variableId].forEach((value, variableIndex) => {
189
+ var _a;
190
+ const firstUnconditionnedIndex = prefillings
191
+ .map((c) => c.conditions === undefined ||
192
+ ConditionsMapper.countConditions(c.conditions) === 0)
193
+ .indexOf(true);
194
+ const prefillingConditions = (_a = selectPrefillerConditionValue(variableId)) === null || _a === void 0 ? void 0 : _a[variableIndex];
195
+ const firstTruthfulPrefill = prefillingConditions === null || prefillingConditions === void 0 ? void 0 : prefillingConditions.indexOf(true);
196
+ const prefillIndex = typeof firstTruthfulPrefill === "number" && firstTruthfulPrefill > -1
197
+ ? firstTruthfulPrefill
198
+ : firstUnconditionnedIndex;
199
+ const prefillerValue = parsePrefillerValue(variableId, variableIndex, prefillIndex);
200
+ if (value.toString().trim().length === 0 || prioritizePrefillings) {
201
+ mpi.dispatch(updateVariableAction(variableId, prefillerValue, variableIndex));
202
+ }
203
+ });
200
204
  }
201
205
  });
202
206
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@legalplace/wizardx-core",
3
- "version": "4.13.1",
3
+ "version": "4.13.2",
4
4
  "author": "Moncef Hammou (moncef@legalplace.fr)",
5
5
  "license": "MIT",
6
6
  "files": [
@@ -96,5 +96,5 @@
96
96
  "*.test.ts",
97
97
  "*.test.tsx"
98
98
  ],
99
- "gitHead": "19728f2e4283a9e854b52405a63281e0c28b0913"
99
+ "gitHead": "3240a0186197e2448190353665f556d64d945bf5"
100
100
  }