@inseefr/lunatic 2.6.3-rc.1 → 2.6.4
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/README.md +49 -3
- package/lib/components/checkbox/checkbox-boolean/html/checkbox-boolean.js +3 -3
- package/lib/components/checkbox/checkbox-boolean/lunatic-checkbox-boolean.js +7 -1
- package/lib/components/checkbox/checkbox-group/checkbox-group-content.js +0 -2
- package/lib/components/checkbox/checkbox-group/html/checkbox-group-content.js +4 -2
- package/lib/components/checkbox/checkbox-group/html/checkbox-group.js +3 -3
- package/lib/components/checkbox/checkbox-group/lunatic-checkbox-group.js +2 -1
- package/lib/components/checkbox/checkbox-one/lunatic-checkbox-one.js +2 -1
- package/lib/components/checkbox/commons/checkbox-option.js +3 -1
- package/lib/components/commons/components/combo-box/combo-box-container.js +1 -2
- package/lib/components/commons/components/combo-box/combo-box.js +2 -2
- package/lib/components/commons/components/combo-box/selection/LabelOrInput.js +3 -1
- package/lib/components/commons/components/combo-box/selection/input.js +3 -1
- package/lib/components/commons/components/combo-box/selection/selection.js +3 -1
- package/lib/components/commons/components/errors/errors.js +12 -10
- package/lib/components/commons/components/errors/errors.spec.js +6 -6
- package/lib/components/component-set/html/__snapshots__/component-set.spec.tsx.snap +2 -0
- package/lib/components/component-set/html/component-set.js +2 -2
- package/lib/components/datepicker/html/__snapshots__/datepicker.spec.tsx.snap +2 -0
- package/lib/components/datepicker/html/datepicker-input.js +4 -2
- package/lib/components/datepicker/html/datepicker.js +3 -3
- package/lib/components/datepicker/lunatic-datepicker.js +2 -1
- package/lib/components/dropdown/lunatic-dropdown.js +2 -1
- package/lib/components/index.js +4 -4
- package/lib/components/input/html/__snapshots__/input.spec.tsx.snap +2 -0
- package/lib/components/input/html/input.js +3 -3
- package/lib/components/input/lunatic-input.js +2 -1
- package/lib/components/input-number/html/__snapshots__/input-number.spec.tsx.snap +2 -2
- package/lib/components/input-number/html/input-number-thousand.js +4 -17
- package/lib/components/input-number/html/input-number.js +3 -5
- package/lib/components/input-number/lunatic-input-number.js +2 -3
- package/lib/components/loop/block-for-loop.js +10 -6
- package/lib/components/loop/roster-for-loop/roster-for-loop.js +35 -27
- package/lib/components/loop/utils/get-initial-nb-rows.js +17 -0
- package/lib/components/lunatic-components.js +7 -27
- package/lib/components/pairwise-links/index.js +13 -0
- package/lib/components/pairwise-links/orchestrator.js +71 -0
- package/lib/components/pairwise-links/pairwise-links.js +30 -27
- package/lib/components/pairwise-links/row.js +74 -0
- package/lib/components/radio/html/radio-group-content.js +4 -2
- package/lib/components/radio/html/radio-group.js +3 -3
- package/lib/components/radio/html/radio-option.js +3 -1
- package/lib/components/radio/lunatic-radio-group.js +2 -1
- package/lib/components/suggester/find-best-label/find-best-label.js +6 -6
- package/lib/components/suggester/idb-suggester/idb-suggester.js +4 -3
- package/lib/components/suggester/lunatic-suggester.js +7 -4
- package/lib/components/suggester/searching/create-searching.js +20 -39
- package/lib/components/switch/html/switch.js +2 -2
- package/lib/components/switch/lunatic-switch.js +2 -1
- package/lib/components/table/cell.js +89 -0
- package/lib/components/table/{table-header.js → header.js} +5 -3
- package/lib/components/table/index.js +13 -0
- package/lib/components/table/lunatic-table.js +15 -24
- package/lib/components/table/row.js +40 -0
- package/lib/components/table/table-orchestrator.js +35 -0
- package/lib/components/textarea/html/__snapshots__/textarea.spec.tsx.snap +2 -0
- package/lib/components/textarea/html/textarea.js +6 -4
- package/lib/components/textarea/lunatic-textarea.js +6 -3
- package/lib/hooks/use-auto-focus.js +26 -0
- package/lib/src/components/checkbox/checkbox-boolean/html/checkbox-boolean.d.ts +1 -1
- package/lib/src/components/checkbox/checkbox-group/html/checkbox-group-content.d.ts +2 -1
- package/lib/src/components/checkbox/checkbox-group/html/checkbox-group.d.ts +1 -1
- package/lib/src/components/checkbox/commons/checkbox-option.d.ts +1 -0
- package/lib/src/components/commons/components/combo-box/combo-box-container.d.ts +2 -2
- package/lib/src/components/commons/components/combo-box/combo-box.d.ts +2 -2
- package/lib/src/components/commons/components/combo-box/combo-box.stories.d.ts +4 -6
- package/lib/src/components/commons/components/combo-box/selection/LabelOrInput.d.ts +1 -0
- package/lib/src/components/commons/components/combo-box/selection/input.d.ts +1 -0
- package/lib/src/components/commons/components/combo-box/selection/selection.d.ts +2 -1
- package/lib/src/components/commons/components/errors/errors.d.ts +6 -3
- package/lib/src/components/datepicker/html/datepicker-input.d.ts +2 -1
- package/lib/src/components/datepicker/html/datepicker.d.ts +1 -1
- package/lib/src/components/dropdown/html/dropdown-writable/dropdown-writable.d.ts +1 -1
- package/lib/src/components/dropdown/html/dropdown.d.ts +3 -1
- package/lib/src/components/index.d.ts +2 -2
- package/lib/src/components/input/html/input.d.ts +2 -2
- package/lib/src/components/input-number/html/input-number-thousand.d.ts +2 -2
- package/lib/src/components/input-number/html/input-number.d.ts +2 -3
- package/lib/src/components/loop/block-for-loop.d.ts +4 -3
- package/lib/src/components/loop/roster-for-loop/roster-for-loop.d.ts +4 -3
- package/lib/src/components/loop/utils/get-initial-nb-rows.d.ts +4 -0
- package/lib/src/components/lunatic-components.d.ts +3 -5
- package/lib/src/components/pairwise-links/index.d.ts +1 -0
- package/lib/src/components/pairwise-links/orchestrator.d.ts +6 -0
- package/lib/src/components/pairwise-links/pairwise-links.d.ts +2 -1
- package/lib/src/components/pairwise-links/row.d.ts +7 -0
- package/lib/src/components/radio/html/radio-group-content.d.ts +2 -1
- package/lib/src/components/radio/html/radio-group.d.ts +1 -1
- package/lib/src/components/radio/html/radio-option.d.ts +1 -0
- package/lib/src/components/suggester/find-best-label/find-best-label.d.ts +1 -1
- package/lib/src/components/suggester/html/suggester.d.ts +1 -1
- package/lib/src/components/suggester/idb-suggester/idb-suggester.d.ts +5 -2
- package/lib/src/components/suggester/lunatic-suggester.d.ts +1 -1
- package/lib/src/components/suggester/searching/create-searching.d.ts +1 -1
- package/lib/src/components/switch/html/switch.d.ts +1 -1
- package/lib/src/components/table/cell.d.ts +19 -0
- package/lib/src/components/table/{table-header.d.ts → header.d.ts} +2 -2
- package/lib/src/components/table/index.d.ts +1 -0
- package/lib/src/components/table/lunatic-table.d.ts +1 -1
- package/lib/src/components/table/row.d.ts +18 -0
- package/lib/src/components/table/table-orchestrator.d.ts +4 -0
- package/lib/src/components/textarea/html/textarea.d.ts +3 -2
- package/lib/src/components/type.d.ts +9 -7
- package/lib/src/hooks/use-auto-focus.d.ts +6 -0
- package/lib/src/use-lunatic/actions.d.ts +19 -3
- package/lib/src/use-lunatic/commons/calculated-variables.d.ts +8 -0
- package/lib/src/use-lunatic/commons/compile-controls.d.ts +2 -3
- package/lib/src/use-lunatic/commons/execute-expression/create-execute-expression.d.ts +9 -0
- package/lib/src/use-lunatic/commons/execute-expression/create-memoizer.d.ts +8 -0
- package/lib/src/use-lunatic/commons/execute-expression/create-refresh-calculated.d.ts +24 -0
- package/lib/src/use-lunatic/commons/execute-expression/execute-expression.d.ts +11 -0
- package/lib/src/use-lunatic/commons/execute-expression/get-expressions-variables.d.ts +7 -0
- package/lib/src/use-lunatic/commons/execute-expression/get-expressions-variables.spec.d.ts +1 -0
- package/lib/src/use-lunatic/commons/execute-expression/get-safety-expression.d.ts +6 -0
- package/lib/src/use-lunatic/commons/execute-expression/index.d.ts +1 -0
- package/lib/src/use-lunatic/commons/fill-components/fill-component-required.d.ts +418 -0
- package/lib/src/use-lunatic/commons/fill-components/fill-component-value.d.ts +3 -2
- package/lib/src/use-lunatic/commons/fill-components/fill-components.d.ts +0 -6
- package/lib/src/use-lunatic/commons/fill-components/fill-from-state.d.ts +142 -107
- package/lib/src/use-lunatic/commons/fill-components/fill-specific-expression.d.ts +89 -53
- package/lib/src/use-lunatic/commons/get-compatible-vtl-expression.d.ts +0 -1
- package/lib/src/use-lunatic/commons/get-component-value/get-component-value.d.ts +6 -0
- package/lib/src/use-lunatic/commons/get-component-value/index.d.ts +1 -0
- package/lib/src/use-lunatic/commons/get-data.d.ts +26 -0
- package/lib/src/use-lunatic/commons/index.d.ts +3 -0
- package/lib/src/use-lunatic/reducer/overview/overview-on-init.d.ts +9 -10
- package/lib/src/use-lunatic/reducer/reduce-handle-change/index.d.ts +1 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-cleaning.d.ts +7 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-cleaning.spec.d.ts +1 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-handle-change.d.ts +4 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-links-variable.d.ts +15 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-missing.d.ts +7 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-resizing.d.ts +4 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-variables-array.d.ts +14 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-variables-simple.d.ts +9 -0
- package/lib/src/use-lunatic/reducer/reduce-on-init.d.ts +12 -1
- package/lib/src/use-lunatic/reducer/reduce-on-init.spec.d.ts +1 -0
- package/lib/src/use-lunatic/type-source.d.ts +21 -7
- package/lib/src/use-lunatic/type.d.ts +12 -13
- package/lib/src/use-lunatic/use-lunatic.d.ts +62 -36
- package/lib/src/use-lunatic/use-suggesters.d.ts +2 -1
- package/lib/src/utils/array.d.ts +1 -6
- package/lib/src/utils/number.d.ts +0 -4
- package/lib/src/utils/suggester-workers/append-to-index/create-append-task.d.ts +1 -1
- package/lib/src/utils/suggester-workers/searching/meloto-order.d.ts +2 -1
- package/lib/src/utils/suggester-workers/worker-path.d.ts +6 -0
- package/lib/src/utils/vtl/dataset-builder.d.ts +5 -0
- package/lib/src/utils/vtl/index.d.ts +1 -0
- package/lib/stories/behaviour/cleaning/source.json +151 -0
- package/lib/stories/behaviour/cleaning/test.stories.js +84 -0
- package/lib/stories/{questionnaires-test → behaviour}/controls/controls.stories.js +5 -5
- package/lib/stories/{questionnaires-test → behaviour/others}/test.stories.js +7 -7
- package/lib/stories/{paste-questionnaire → behaviour/paste}/test.stories.js +3 -3
- package/lib/stories/{resizing-questionnaire → behaviour/resizing}/test.stories.js +3 -3
- package/lib/stories/suggester/suggester-workers.stories.js +36 -1
- package/lib/stories/suggester/suggester.stories.js +8 -4
- package/lib/use-lunatic/actions.js +3 -3
- package/lib/use-lunatic/commons/calculated-variables.js +104 -0
- package/lib/use-lunatic/commons/compile-controls.js +5 -3
- package/lib/use-lunatic/commons/execute-condition-filter.js +9 -1
- package/lib/use-lunatic/commons/execute-expression/create-execute-expression.js +233 -0
- package/lib/use-lunatic/commons/execute-expression/create-execute-expression.spec.js +155 -0
- package/lib/use-lunatic/commons/execute-expression/create-memoizer.js +63 -0
- package/lib/use-lunatic/commons/execute-expression/create-refresh-calculated.js +149 -0
- package/lib/use-lunatic/commons/execute-expression/create-refresh-calculated.spec.js +130 -0
- package/lib/use-lunatic/commons/execute-expression/execute-expression.js +90 -0
- package/lib/use-lunatic/commons/execute-expression/execute-expression.spec.js +38 -0
- package/lib/use-lunatic/commons/execute-expression/get-expressions-variables.js +40 -0
- package/lib/use-lunatic/commons/execute-expression/get-expressions-variables.spec.js +31 -0
- package/lib/use-lunatic/commons/{fill-components/fill-iterations.js → execute-expression/get-safety-expression.js} +20 -30
- package/lib/use-lunatic/commons/execute-expression/index.js +13 -0
- package/lib/use-lunatic/commons/fill-components/fill-component-expressions.js +3 -2
- package/lib/use-lunatic/{reducer/reduce-handle-change.js → commons/fill-components/fill-component-required.js} +8 -14
- package/lib/use-lunatic/commons/fill-components/fill-component-value.js +7 -21
- package/lib/use-lunatic/commons/fill-components/fill-components.js +4 -5
- package/lib/use-lunatic/commons/fill-components/fill-from-state.js +2 -0
- package/lib/use-lunatic/commons/fill-components/fill-missing-response.js +13 -6
- package/lib/use-lunatic/commons/fill-components/fill-specific-expression.js +5 -58
- package/lib/use-lunatic/commons/get-compatible-vtl-expression.js +0 -1
- package/lib/use-lunatic/commons/get-component-value/get-component-value.js +174 -0
- package/lib/use-lunatic/commons/get-component-value/index.js +13 -0
- package/lib/use-lunatic/commons/get-data.js +80 -0
- package/lib/use-lunatic/commons/index.js +21 -0
- package/lib/use-lunatic/initial-state.js +4 -6
- package/lib/use-lunatic/reducer/overview/overview-on-change.js +1 -1
- package/lib/use-lunatic/reducer/reduce-handle-change/__mocks__/source-cleaning-loop.json +792 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/index.js +13 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-cleaning.js +78 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-cleaning.spec.js +46 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-handle-change.js +115 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-links-variable.js +89 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-missing.js +88 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-resizing.js +119 -0
- package/lib/use-lunatic/{commons/variables/get-questionnaire-data.js → reducer/reduce-handle-change/reduce-variables-array.js} +32 -53
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-variables-simple.js +28 -0
- package/lib/use-lunatic/reducer/reduce-on-init.js +184 -90
- package/lib/use-lunatic/reducer/reduce-on-init.spec.js +17 -0
- package/lib/use-lunatic/reducer/reducer.js +2 -2
- package/lib/use-lunatic/reducer/resolve-component-controls/resolve-simple-control.js +4 -2
- package/lib/use-lunatic/use-lunatic.js +29 -22
- package/lib/use-lunatic/use-lunatic.test.js +36 -133
- package/lib/use-lunatic/use-suggesters.js +4 -3
- package/lib/utils/array.js +6 -57
- package/lib/utils/get-component-value.js +9 -3
- package/lib/utils/number.js +1 -13
- package/lib/utils/suggester-workers/append-to-index/create-append-task.js +4 -3
- package/lib/utils/suggester-workers/searching/meloto-order.js +6 -5
- package/lib/utils/suggester-workers/worker-path.js +29 -0
- package/lib/utils/vtl/dataset-builder.js +27 -0
- package/lib/utils/vtl/index.js +13 -0
- package/package.json +15 -10
- package/scripts/build/add-workers-to-public.js +44 -0
- package/scripts/build/workers-paths.js +44 -0
- package/workers-release/lunatic-append-worker-0.3.0-experimental.js +2 -0
- package/workers-release/lunatic-append-worker-0.3.0-experimental.js.LICENSE.txt +34 -0
- package/workers-release/lunatic-label-worker-0.3.0-experimental.js +2 -0
- package/workers-release/lunatic-label-worker-0.3.0-experimental.js.LICENSE.txt +13 -0
- package/workers-release/lunatic-searching-worker-0.3.0-experimental.js +2 -0
- package/workers-release/lunatic-searching-worker-0.3.0-experimental.js.LICENSE.txt +34 -0
- package/lib/hooks/use-track-changes.js +0 -50
- package/lib/src/hooks/use-track-changes.d.ts +0 -9
- package/lib/src/use-lunatic/commons/component.d.ts +0 -22
- package/lib/src/use-lunatic/commons/fill-components/fill-iterations.d.ts +0 -112
- package/lib/src/use-lunatic/commons/variables/behaviours/cleaning-behaviour.d.ts +0 -7
- package/lib/src/use-lunatic/commons/variables/behaviours/missing-behaviour.d.ts +0 -7
- package/lib/src/use-lunatic/commons/variables/behaviours/resizing-behaviour.d.ts +0 -7
- package/lib/src/use-lunatic/commons/variables/get-questionnaire-data.d.ts +0 -4
- package/lib/src/use-lunatic/commons/variables/lunatic-variables-store.d.ts +0 -77
- package/lib/src/use-lunatic/reducer/reduce-handle-change.d.ts +0 -6
- package/lib/src/utils/env.d.ts +0 -1
- package/lib/src/utils/store-tools/worker-path.d.ts +0 -1
- package/lib/src/utils/variables.d.ts +0 -5
- package/lib/src/utils/vtl.d.ts +0 -14
- package/lib/use-lunatic/commons/component.js +0 -22
- package/lib/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js +0 -39
- package/lib/use-lunatic/commons/variables/behaviours/missing-behaviour.js +0 -47
- package/lib/use-lunatic/commons/variables/behaviours/resizing-behaviour.js +0 -78
- package/lib/use-lunatic/commons/variables/lunatic-variables-store.js +0 -330
- package/lib/use-lunatic/commons/variables/lunatic-variables-store.spec.js +0 -216
- package/lib/utils/array.spec.js +0 -30
- package/lib/utils/env.js +0 -10
- package/lib/utils/store-tools/worker-path.js +0 -13
- package/lib/utils/suggester-workers/create-worker.js +0 -55
- package/lib/utils/variables.js +0 -37
- package/lib/utils/vtl.js +0 -100
- /package/lib/src/use-lunatic/commons/{variables/lunatic-variables-store.spec.d.ts → execute-expression/create-refresh-calculated.spec.d.ts} +0 -0
- /package/lib/src/{utils/array.spec.d.ts → use-lunatic/commons/execute-expression/execute-expression.spec.d.ts} +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_ControlesNonNum_horsBoucle_PasPageFin.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_ControlesNum_horsBoucle_PasPageFin.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_Controles_BouclesLiees2_PasPageFin.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_Controles_BouclesLiees_PasPageFin.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/boucles-n.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/controls-externes.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/controls-externes.stories.js +0 -0
- /package/lib/stories/{questionnaires-test → behaviour/others}/V2_DeclarationsSimples.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour/others}/V2_MinMaxSum_Boucles.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour/others}/V2_QuestSimple_Boucles.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour/others}/V2_TCMRallyeGames.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour/others}/test-dylan.json +0 -0
- /package/lib/stories/{paste-questionnaire → behaviour/paste}/source.json +0 -0
- /package/lib/stories/{resizing-questionnaire → behaviour/resizing}/source.json +0 -0
|
@@ -1,65 +1,44 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
|
-
exports
|
|
7
|
-
|
|
8
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
9
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
10
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
|
+
exports["default"] = void 0;
|
|
8
|
+
var _commons = require("../commons");
|
|
11
9
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
12
10
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
13
11
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
14
12
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
15
13
|
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
16
|
-
function
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
14
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
15
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
16
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
17
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
18
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
19
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
20
|
+
/**
|
|
21
|
+
* Inject the value at a specific index (and resize the value if necessary)
|
|
22
|
+
*/
|
|
23
|
+
function reduceVariablesArray(variables, args) {
|
|
24
|
+
var name = args.name,
|
|
25
|
+
value = args.value,
|
|
26
|
+
index = args.index,
|
|
27
|
+
length = args.length;
|
|
28
|
+
if (name in variables) {
|
|
29
|
+
var variable = variables[name];
|
|
30
|
+
var previousValue = variable.value;
|
|
27
31
|
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
PREVIOUS: null,
|
|
37
|
-
COLLECTED: store.get(name)
|
|
38
|
-
}];
|
|
39
|
-
}))
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
var _iterator = _createForOfIteratorHelper(variables),
|
|
43
|
-
_step;
|
|
44
|
-
try {
|
|
45
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
46
|
-
var variable = _step.value;
|
|
47
|
-
// Skip calculated value if necessary
|
|
48
|
-
if (variable.variableType === 'CALCULATED' && !withCalculated) {
|
|
49
|
-
continue;
|
|
50
|
-
}
|
|
51
|
-
if (variable.variableType === 'COLLECTED') {
|
|
52
|
-
result.COLLECTED[variable.name] = _objectSpread(_objectSpread({}, variable.values), {}, {
|
|
53
|
-
COLLECTED: store.get(variable.name)
|
|
54
|
-
});
|
|
55
|
-
} else {
|
|
56
|
-
result[variable.variableType][variable.name] = store.get(variable.name);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
} catch (err) {
|
|
60
|
-
_iterator.e(err);
|
|
61
|
-
} finally {
|
|
62
|
-
_iterator.f();
|
|
32
|
+
// Ensure the value is an array of corresponding size
|
|
33
|
+
var valueNext = _toConsumableArray((0, _commons.resizeArrayVariable)(previousValue, length));
|
|
34
|
+
|
|
35
|
+
// Inject the new value at the corresponding index
|
|
36
|
+
valueNext[index] = value;
|
|
37
|
+
return _objectSpread(_objectSpread({}, variables), {}, _defineProperty({}, name, _objectSpread(_objectSpread({}, variable), {}, {
|
|
38
|
+
value: valueNext
|
|
39
|
+
})));
|
|
63
40
|
}
|
|
64
|
-
return
|
|
65
|
-
}
|
|
41
|
+
return variables;
|
|
42
|
+
}
|
|
43
|
+
var _default = reduceVariablesArray;
|
|
44
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
8
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
12
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
13
|
+
/**
|
|
14
|
+
* Add the value for the variable in the corresponding variable object
|
|
15
|
+
*/
|
|
16
|
+
function reduceVariablesSimple(variables, _ref) {
|
|
17
|
+
var name = _ref.name,
|
|
18
|
+
value = _ref.value;
|
|
19
|
+
if (name in variables) {
|
|
20
|
+
var variable = variables[name];
|
|
21
|
+
return _objectSpread(_objectSpread({}, variables), {}, _defineProperty({}, name, _objectSpread(_objectSpread({}, variable), {}, {
|
|
22
|
+
value: value
|
|
23
|
+
})));
|
|
24
|
+
}
|
|
25
|
+
return variables;
|
|
26
|
+
}
|
|
27
|
+
var _default = reduceVariablesSimple;
|
|
28
|
+
exports["default"] = _default;
|
|
@@ -8,24 +8,139 @@ var _commons = require("../commons");
|
|
|
8
8
|
var _compose = _interopRequireDefault(require("../commons/compose"));
|
|
9
9
|
var _pageTag = require("../commons/page-tag");
|
|
10
10
|
var _overviewOnInit = require("./overview/overview-on-init");
|
|
11
|
-
var _lunaticVariablesStore = require("../commons/variables/lunatic-variables-store");
|
|
12
|
-
var _constants = require("../../utils/constants");
|
|
13
|
-
var _mdLabel = _interopRequireDefault(require("../../components/commons/components/md-label"));
|
|
14
|
-
var _vtl = require("../../utils/vtl");
|
|
15
|
-
var _number = require("../../utils/number");
|
|
16
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
17
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
18
12
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
13
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
14
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15
|
+
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
16
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
17
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
18
|
+
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
19
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
20
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
21
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
22
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
19
23
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
20
24
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
25
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
22
26
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
23
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
28
|
+
/**
|
|
29
|
+
* Extract value from colllected data
|
|
30
|
+
*/
|
|
31
|
+
function getInitalValueFromCollected(variable, data) {
|
|
32
|
+
var name = variable.name;
|
|
33
|
+
var fromData;
|
|
34
|
+
if (data && name in data) {
|
|
35
|
+
var _data$name = data[name],
|
|
36
|
+
COLLECTED = _data$name.COLLECTED,
|
|
37
|
+
FORCED = _data$name.FORCED;
|
|
38
|
+
fromData = COLLECTED !== null && COLLECTED !== void 0 ? COLLECTED : FORCED;
|
|
39
|
+
}
|
|
40
|
+
if ('values' in variable && variable.values) {
|
|
41
|
+
var _ref, _fromData;
|
|
42
|
+
var _variable$values = variable.values,
|
|
43
|
+
_COLLECTED = _variable$values.COLLECTED,
|
|
44
|
+
_FORCED = _variable$values.FORCED;
|
|
45
|
+
return (_ref = (_fromData = fromData) !== null && _fromData !== void 0 ? _fromData : _FORCED) !== null && _ref !== void 0 ? _ref : _COLLECTED;
|
|
46
|
+
}
|
|
47
|
+
return undefined;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/**
|
|
51
|
+
* Extract value from an external data
|
|
52
|
+
*/
|
|
53
|
+
function getInitialValueFromExternal(variable) {
|
|
54
|
+
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
55
|
+
var name = variable.name;
|
|
56
|
+
return data === null || data === void 0 ? void 0 : data[name];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* Extract value from data for the variable
|
|
61
|
+
*/
|
|
62
|
+
function getInitialValue(variable) {
|
|
63
|
+
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
64
|
+
var COLLECTED = data.COLLECTED,
|
|
65
|
+
EXTERNAL = data.EXTERNAL,
|
|
66
|
+
CALCULATED = data.CALCULATED;
|
|
67
|
+
switch (variable.variableType) {
|
|
68
|
+
case 'COLLECTED':
|
|
69
|
+
return getInitalValueFromCollected(variable, COLLECTED);
|
|
70
|
+
case 'EXTERNAL':
|
|
71
|
+
return getInitialValueFromExternal(variable, EXTERNAL);
|
|
72
|
+
case 'CALCULATED':
|
|
73
|
+
return getInitialValueFromExternal(variable, CALCULATED);
|
|
74
|
+
default:
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
function appendToArrayMap(map, key, entry) {
|
|
79
|
+
if (key in map) {
|
|
80
|
+
return _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, key, [].concat(_toConsumableArray(map[key]), [entry])));
|
|
81
|
+
}
|
|
82
|
+
return _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, key, [entry]));
|
|
83
|
+
}
|
|
84
|
+
function appendToObjectMap(map, variable, value) {
|
|
85
|
+
var key = variable.name;
|
|
86
|
+
var object = {
|
|
87
|
+
variable: variable,
|
|
88
|
+
value: value,
|
|
89
|
+
type: variable.variableType
|
|
90
|
+
};
|
|
91
|
+
if (key in map) {
|
|
92
|
+
return _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, key, _objectSpread(_objectSpread({}, map[key]), object)));
|
|
93
|
+
}
|
|
94
|
+
return _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, key, object));
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
/**
|
|
98
|
+
* Creates the variables object to set in the state
|
|
99
|
+
*/
|
|
100
|
+
function createVariables(source, data) {
|
|
101
|
+
var _source$variables = source.variables,
|
|
102
|
+
variables = _source$variables === void 0 ? [] : _source$variables;
|
|
103
|
+
var _variables$reduce = variables.reduce(function (_ref2, variable) {
|
|
104
|
+
var _ref3 = _slicedToArray(_ref2, 2),
|
|
105
|
+
mapType = _ref3[0],
|
|
106
|
+
mapVar = _ref3[1];
|
|
107
|
+
var type = variable.variableType;
|
|
108
|
+
return [appendToArrayMap(mapType, type, variable), appendToObjectMap(mapVar, variable, getInitialValue(variable, data))];
|
|
109
|
+
}, [{
|
|
110
|
+
EXTERNAL: [],
|
|
111
|
+
COLLECTED: [],
|
|
112
|
+
CALCULATED: []
|
|
113
|
+
}, {}]),
|
|
114
|
+
_variables$reduce2 = _slicedToArray(_variables$reduce, 2),
|
|
115
|
+
mapVariablesTypes = _variables$reduce2[0],
|
|
116
|
+
mapVariables = _variables$reduce2[1];
|
|
117
|
+
var _mapVariablesTypes$CA = mapVariablesTypes.CALCULATED,
|
|
118
|
+
CALCULATED = _mapVariablesTypes$CA === void 0 ? [] : _mapVariablesTypes$CA;
|
|
119
|
+
CALCULATED.forEach(function (calculated) {
|
|
120
|
+
var _calculated$bindingDe = calculated.bindingDependencies,
|
|
121
|
+
bindingDependencies = _calculated$bindingDe === void 0 ? [] : _calculated$bindingDe;
|
|
122
|
+
bindingDependencies.forEach(function (name) {
|
|
123
|
+
if (name in mapVariables) {
|
|
124
|
+
var variable = mapVariables[name];
|
|
125
|
+
var CalculatedLinked = variable.CalculatedLinked;
|
|
126
|
+
if (CalculatedLinked) {
|
|
127
|
+
CalculatedLinked.push(calculated);
|
|
128
|
+
} else {
|
|
129
|
+
variable.CalculatedLinked = [calculated];
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
});
|
|
133
|
+
});
|
|
134
|
+
return mapVariables;
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
/**
|
|
138
|
+
* Check if there is a loop and populate the pager accordingly
|
|
139
|
+
*/
|
|
140
|
+
function checkInLoop(state, initialPager) {
|
|
27
141
|
var pager = state.pager,
|
|
28
|
-
pages = state.pages
|
|
142
|
+
pages = state.pages,
|
|
143
|
+
executeExpression = state.executeExpression;
|
|
29
144
|
var page = pager.page;
|
|
30
145
|
if (page in pages) {
|
|
31
146
|
var _pages$page = pages[page],
|
|
@@ -41,9 +156,10 @@ function fillLoopState(state, initialPager) {
|
|
|
41
156
|
subPage: (_initialPager$subPage = initialPager === null || initialPager === void 0 ? void 0 : initialPager.subPage) !== null && _initialPager$subPage !== void 0 ? _initialPager$subPage : 0,
|
|
42
157
|
nbSubPages: (subPages !== null && subPages !== void 0 ? subPages : []).length,
|
|
43
158
|
iteration: (_initialPager$iterati = initialPager === null || initialPager === void 0 ? void 0 : initialPager.iteration) !== null && _initialPager$iterati !== void 0 ? _initialPager$iterati : 0,
|
|
44
|
-
nbIterations:
|
|
45
|
-
|
|
46
|
-
|
|
159
|
+
nbIterations: executeExpression(iterations, {
|
|
160
|
+
iteration: undefined,
|
|
161
|
+
bindingDependencies: loopDependencies
|
|
162
|
+
})
|
|
47
163
|
})
|
|
48
164
|
});
|
|
49
165
|
}
|
|
@@ -51,12 +167,12 @@ function fillLoopState(state, initialPager) {
|
|
|
51
167
|
return state;
|
|
52
168
|
}
|
|
53
169
|
function reduceOnInit(state, action) {
|
|
54
|
-
var _initialPager$page;
|
|
55
170
|
var payload = action.payload;
|
|
56
171
|
var source = payload.source,
|
|
57
172
|
data = payload.data,
|
|
58
173
|
initialPage = payload.initialPage,
|
|
59
174
|
lastReachedPage = payload.lastReachedPage,
|
|
175
|
+
features = payload.features,
|
|
60
176
|
handleChange = payload.handleChange,
|
|
61
177
|
preferences = payload.preferences,
|
|
62
178
|
savingType = payload.savingType,
|
|
@@ -65,82 +181,60 @@ function reduceOnInit(state, action) {
|
|
|
65
181
|
activeControls = payload.activeControls,
|
|
66
182
|
goToPage = payload.goToPage,
|
|
67
183
|
goNextPage = payload.goNextPage,
|
|
68
|
-
goPreviousPage = payload.goPreviousPage
|
|
69
|
-
|
|
70
|
-
|
|
184
|
+
goPreviousPage = payload.goPreviousPage,
|
|
185
|
+
workersBasePath = payload.workersBasePath;
|
|
186
|
+
if (source && data) {
|
|
187
|
+
var _initialPager$page;
|
|
188
|
+
var variables = createVariables(source, data); // map des variables
|
|
189
|
+
var _createExecuteExpress = (0, _commons.createExecuteExpression)(variables, features),
|
|
190
|
+
_createExecuteExpress2 = _slicedToArray(_createExecuteExpress, 2),
|
|
191
|
+
executeExpression = _createExecuteExpress2[0],
|
|
192
|
+
updateBindings = _createExecuteExpress2[1];
|
|
193
|
+
var pages = (0, _commons.checkLoops)((0, _commons.createMapPages)(source));
|
|
194
|
+
var maxPage = source.maxPage,
|
|
195
|
+
_source$cleaning = source.cleaning,
|
|
196
|
+
cleaning = _source$cleaning === void 0 ? {} : _source$cleaning,
|
|
197
|
+
_source$missingBlock = source.missingBlock,
|
|
198
|
+
missingBlock = _source$missingBlock === void 0 ? {} : _source$missingBlock,
|
|
199
|
+
_source$resizing = source.resizing,
|
|
200
|
+
resizing = _source$resizing === void 0 ? {} : _source$resizing;
|
|
201
|
+
var initialPager = (0, _pageTag.getPagerFromPageTag)(initialPage);
|
|
202
|
+
var pager = {
|
|
203
|
+
page: (_initialPager$page = initialPager === null || initialPager === void 0 ? void 0 : initialPager.page) !== null && _initialPager$page !== void 0 ? _initialPager$page : '1',
|
|
204
|
+
maxPage: maxPage,
|
|
205
|
+
subPage: undefined,
|
|
206
|
+
nbSubPages: undefined,
|
|
207
|
+
iteration: undefined,
|
|
208
|
+
nbIterations: undefined,
|
|
209
|
+
lastReachedPage: lastReachedPage !== null && lastReachedPage !== void 0 ? lastReachedPage : initialPage
|
|
210
|
+
};
|
|
211
|
+
var _isFirstLastPage = (0, _commons.isFirstLastPage)(pager),
|
|
212
|
+
isFirstPage = _isFirstLastPage.isFirstPage,
|
|
213
|
+
isLastPage = _isFirstLastPage.isLastPage;
|
|
214
|
+
return checkInLoop(_objectSpread(_objectSpread({}, state), {}, {
|
|
215
|
+
cleaning: cleaning,
|
|
216
|
+
missingBlock: missingBlock,
|
|
217
|
+
resizing: resizing,
|
|
218
|
+
variables: variables,
|
|
219
|
+
pages: pages,
|
|
220
|
+
isFirstPage: isFirstPage,
|
|
221
|
+
isLastPage: isLastPage,
|
|
222
|
+
pager: pager,
|
|
223
|
+
executeExpression: executeExpression,
|
|
224
|
+
updateBindings: updateBindings,
|
|
225
|
+
handleChange: handleChange,
|
|
226
|
+
preferences: preferences,
|
|
227
|
+
management: management,
|
|
228
|
+
savingType: savingType,
|
|
229
|
+
activeControls: activeControls,
|
|
230
|
+
goToPage: goToPage,
|
|
231
|
+
goNextPage: goNextPage,
|
|
232
|
+
goPreviousPage: goPreviousPage,
|
|
233
|
+
shortcut: shortcut,
|
|
234
|
+
workersBasePath: workersBasePath
|
|
235
|
+
}), initialPager);
|
|
71
236
|
}
|
|
72
|
-
|
|
73
|
-
var pages = (0, _commons.checkLoops)((0, _commons.createMapPages)(source));
|
|
74
|
-
var maxPage = source.maxPage,
|
|
75
|
-
_source$cleaning = source.cleaning,
|
|
76
|
-
cleaning = _source$cleaning === void 0 ? {} : _source$cleaning,
|
|
77
|
-
_source$missingBlock = source.missingBlock,
|
|
78
|
-
missingBlock = _source$missingBlock === void 0 ? {} : _source$missingBlock;
|
|
79
|
-
var initialPager = (0, _pageTag.getPagerFromPageTag)(initialPage);
|
|
80
|
-
var pager = {
|
|
81
|
-
page: (_initialPager$page = initialPager === null || initialPager === void 0 ? void 0 : initialPager.page) !== null && _initialPager$page !== void 0 ? _initialPager$page : '1',
|
|
82
|
-
maxPage: maxPage,
|
|
83
|
-
subPage: undefined,
|
|
84
|
-
nbSubPages: undefined,
|
|
85
|
-
iteration: undefined,
|
|
86
|
-
nbIterations: undefined,
|
|
87
|
-
lastReachedPage: lastReachedPage !== null && lastReachedPage !== void 0 ? lastReachedPage : initialPage
|
|
88
|
-
};
|
|
89
|
-
var executeExpression = function executeExpression(expression) {
|
|
90
|
-
var args = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
91
|
-
// This is kept to ensure backward compatibility
|
|
92
|
-
if (args !== null && args !== void 0 && args.bindingDependencies) {
|
|
93
|
-
args.deps = args.bindingDependencies;
|
|
94
|
-
}
|
|
95
|
-
// Remove above code on next update
|
|
96
|
-
var expressionType = (0, _vtl.getExpressionType)(expression);
|
|
97
|
-
var features = action.payload.features;
|
|
98
|
-
if (!features.includes(_constants.VTL) || !expressionType.includes(_constants.VTL)) {
|
|
99
|
-
return expression;
|
|
100
|
-
}
|
|
101
|
-
var expressionString = (0, _vtl.getExpressionAsString)(expression);
|
|
102
|
-
try {
|
|
103
|
-
var result = variables.run(expressionString, _objectSpread(_objectSpread({}, args), {}, {
|
|
104
|
-
iteration: typeof args.iteration === 'number' ? [args.iteration] : args.iteration
|
|
105
|
-
}));
|
|
106
|
-
if (features.includes(_constants.MD) && expressionType.includes(_constants.MD) && typeof result === 'string') {
|
|
107
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_mdLabel["default"], {
|
|
108
|
-
expression: result
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
return result;
|
|
112
|
-
} catch (e) {
|
|
113
|
-
// If there is an error interpreting a variable, return the raw expression
|
|
114
|
-
console.error("Cannot interpret expression : ".concat(expressionString));
|
|
115
|
-
return expressionString;
|
|
116
|
-
}
|
|
117
|
-
};
|
|
118
|
-
var updateBindings = function updateBindings(variableName, value, options) {
|
|
119
|
-
variables.set(variableName, value, options);
|
|
120
|
-
};
|
|
121
|
-
var _isFirstLastPage = (0, _commons.isFirstLastPage)(pager),
|
|
122
|
-
isFirstPage = _isFirstLastPage.isFirstPage,
|
|
123
|
-
isLastPage = _isFirstLastPage.isLastPage;
|
|
124
|
-
return fillLoopState(_objectSpread(_objectSpread({}, state), {}, {
|
|
125
|
-
cleaning: cleaning,
|
|
126
|
-
missingBlock: missingBlock,
|
|
127
|
-
variables: variables,
|
|
128
|
-
pages: pages,
|
|
129
|
-
isFirstPage: isFirstPage,
|
|
130
|
-
isLastPage: isLastPage,
|
|
131
|
-
pager: pager,
|
|
132
|
-
executeExpression: executeExpression,
|
|
133
|
-
updateBindings: updateBindings,
|
|
134
|
-
handleChange: handleChange,
|
|
135
|
-
preferences: preferences,
|
|
136
|
-
management: management,
|
|
137
|
-
savingType: savingType,
|
|
138
|
-
activeControls: activeControls,
|
|
139
|
-
goToPage: goToPage,
|
|
140
|
-
goNextPage: goNextPage,
|
|
141
|
-
goPreviousPage: goPreviousPage,
|
|
142
|
-
shortcut: shortcut
|
|
143
|
-
}), initialPager);
|
|
237
|
+
return state;
|
|
144
238
|
}
|
|
145
239
|
var reducers = (0, _compose["default"])(reduceOnInit, _overviewOnInit.reduceOverviewOnInit);
|
|
146
240
|
var _default = reducers;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _vitest = require("vitest");
|
|
4
|
+
var _source = _interopRequireDefault(require("../../stories/radio/source.json"));
|
|
5
|
+
var _lunatic = require("../../../tests/utils/lunatic");
|
|
6
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
7
|
+
(0, _vitest.describe)('reduce-on-init', function () {
|
|
8
|
+
(0, _vitest.describe)('init variables', function () {
|
|
9
|
+
(0, _vitest.it)('should init false variable correctly', function () {
|
|
10
|
+
var state = (0, _lunatic.generateState)(_source["default"], {
|
|
11
|
+
Q2: false
|
|
12
|
+
});
|
|
13
|
+
(0, _vitest.expect)(state.variables).toHaveProperty('Q2');
|
|
14
|
+
(0, _vitest.expect)(state.variables.Q2.value).toEqual(false);
|
|
15
|
+
});
|
|
16
|
+
});
|
|
17
|
+
});
|
|
@@ -8,7 +8,7 @@ var _actions = require("../actions");
|
|
|
8
8
|
var _reduceGoNextPage = require("./reduce-go-next-page");
|
|
9
9
|
var _reduceGoPreviousPage = _interopRequireDefault(require("./reduce-go-previous-page"));
|
|
10
10
|
var _reduceGoToPage = _interopRequireDefault(require("./reduce-go-to-page"));
|
|
11
|
-
var _reduceHandleChange = require("./reduce-handle-change");
|
|
11
|
+
var _reduceHandleChange = _interopRequireDefault(require("./reduce-handle-change"));
|
|
12
12
|
var _reduceOnInit = _interopRequireDefault(require("./reduce-on-init"));
|
|
13
13
|
var _reduceOnSetWaiting = _interopRequireDefault(require("./reduce-on-set-waiting"));
|
|
14
14
|
var _reduceUpdateState = require("./reduce-update-state");
|
|
@@ -24,7 +24,7 @@ function reducer(state, action) {
|
|
|
24
24
|
case _actions.ActionKind.GO_TO_PAGE:
|
|
25
25
|
return (0, _reduceGoToPage["default"])(state, action);
|
|
26
26
|
case _actions.ActionKind.HANDLE_CHANGE:
|
|
27
|
-
return (0, _reduceHandleChange
|
|
27
|
+
return (0, _reduceHandleChange["default"])(state, action);
|
|
28
28
|
case _actions.ActionKind.ON_SET_WAITING:
|
|
29
29
|
return (0, _reduceOnSetWaiting["default"])(state, action);
|
|
30
30
|
case _actions.ActionKind.UPDATE_STATE:
|
|
@@ -16,7 +16,8 @@ function resolveSimpleControl(state, control) {
|
|
|
16
16
|
typeOfControl = control.typeOfControl;
|
|
17
17
|
var value = (_control$control$valu = control === null || control === void 0 || (_control$control = control.control) === null || _control$control === void 0 ? void 0 : _control$control.value) !== null && _control$control$valu !== void 0 ? _control$control$valu : 'true';
|
|
18
18
|
var result = executeExpression(value, {
|
|
19
|
-
iteration:
|
|
19
|
+
iteration: iteration,
|
|
20
|
+
linksIterations: linksIterations
|
|
20
21
|
});
|
|
21
22
|
try {
|
|
22
23
|
/**
|
|
@@ -27,7 +28,8 @@ function resolveSimpleControl(state, control) {
|
|
|
27
28
|
*/
|
|
28
29
|
if (result) return undefined;
|
|
29
30
|
var label = executeExpression(errorMessage, {
|
|
30
|
-
iteration: iteration
|
|
31
|
+
iteration: iteration,
|
|
32
|
+
linksIterations: linksIterations
|
|
31
33
|
});
|
|
32
34
|
return {
|
|
33
35
|
criticality: criticality,
|
|
@@ -10,18 +10,22 @@ var actions = _interopRequireWildcard(require("./actions"));
|
|
|
10
10
|
var _commons = require("./commons");
|
|
11
11
|
var _i18n = _interopRequireDefault(require("../i18n"));
|
|
12
12
|
var _constants = require("../utils/constants");
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var _compileControls = require("./commons/compile-controls");
|
|
13
|
+
var _compileControls = _interopRequireDefault(require("./commons/compile-controls"));
|
|
14
|
+
var _getData = require("./commons/get-data");
|
|
16
15
|
var _getOverview = require("./commons/getOverview");
|
|
17
16
|
var _useLoopVariables = require("./hooks/use-loop-variables");
|
|
17
|
+
var _initialState = _interopRequireDefault(require("./initial-state"));
|
|
18
|
+
var _lunaticContext = require("./lunatic-context");
|
|
18
19
|
var _reducer = _interopRequireDefault(require("./reducer"));
|
|
19
20
|
var _useSuggesters = require("./use-suggesters");
|
|
20
|
-
var _getQuestionnaireData = require("./commons/variables/get-questionnaire-data");
|
|
21
|
-
var _useTrackChanges2 = require("../hooks/use-track-changes");
|
|
22
21
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
23
22
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
24
23
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
24
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
25
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
26
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
27
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
28
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
25
29
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
26
30
|
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
27
31
|
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
@@ -78,8 +82,8 @@ function useLunatic(source) {
|
|
|
78
82
|
dontKnowButton = _ref$dontKnowButton === void 0 ? DEFAULT_DONT_KNOW : _ref$dontKnowButton,
|
|
79
83
|
_ref$refusedButton = _ref.refusedButton,
|
|
80
84
|
refusedButton = _ref$refusedButton === void 0 ? DEFAULT_REFUSED : _ref$refusedButton,
|
|
81
|
-
_ref$
|
|
82
|
-
|
|
85
|
+
_ref$workersBasePath = _ref.workersBasePath,
|
|
86
|
+
workersBasePath = _ref$workersBasePath === void 0 ? undefined : _ref$workersBasePath;
|
|
83
87
|
var _useReducer = (0, _react.useReducer)(_reducer["default"], _initialState["default"]),
|
|
84
88
|
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
85
89
|
state = _useReducer2[0],
|
|
@@ -109,10 +113,11 @@ function useLunatic(source) {
|
|
|
109
113
|
var getSuggesterStatus = (0, _useSuggesters.useSuggesters)({
|
|
110
114
|
auto: autoSuggesterLoading,
|
|
111
115
|
getReferentiel: getReferentiel,
|
|
112
|
-
suggesters: suggesters
|
|
116
|
+
suggesters: suggesters,
|
|
117
|
+
workersBasePath: workersBasePath
|
|
113
118
|
});
|
|
114
119
|
var compileControls = (0, _react.useCallback)(function () {
|
|
115
|
-
return (0, _compileControls
|
|
120
|
+
return (0, _compileControls["default"])({
|
|
116
121
|
pager: pager,
|
|
117
122
|
pages: pages,
|
|
118
123
|
isInLoop: isInLoop,
|
|
@@ -149,17 +154,20 @@ function useLunatic(source) {
|
|
|
149
154
|
return components;
|
|
150
155
|
}, [components]);
|
|
151
156
|
var handleChange = (0, _react.useCallback)(function (response, value, args) {
|
|
152
|
-
dispatch(actions.handleChange(typeof response === 'string' ?
|
|
157
|
+
dispatch(actions.handleChange(typeof response === 'string' ? {
|
|
158
|
+
name: response
|
|
159
|
+
} : response, value, _objectSpread(_objectSpread({}, args), {}, {
|
|
160
|
+
onChange: onChange
|
|
161
|
+
})));
|
|
153
162
|
onChange(response, value, args);
|
|
154
163
|
}, [dispatch, onChange]);
|
|
155
|
-
var getData = function getData(withRefreshedCalculated
|
|
156
|
-
|
|
164
|
+
var getData = function getData(withRefreshedCalculated) {
|
|
165
|
+
var variables = state.variables;
|
|
166
|
+
return (0, _getData.getQuestionnaireData)({
|
|
167
|
+
variables: variables,
|
|
168
|
+
withRefreshedCalculated: withRefreshedCalculated
|
|
169
|
+
});
|
|
157
170
|
};
|
|
158
|
-
var _useTrackChanges = (0, _useTrackChanges2.useTrackChanges)(trackChanges, state.variables, function (variableNames) {
|
|
159
|
-
return getData(false, variableNames);
|
|
160
|
-
}),
|
|
161
|
-
resetChangedData = _useTrackChanges.resetChangedData,
|
|
162
|
-
getChangedData = _useTrackChanges.getChangedData;
|
|
163
171
|
var buildedOverview = (0, _react.useMemo)(function () {
|
|
164
172
|
return (0, _getOverview.overviewWithChildren)(overview);
|
|
165
173
|
}, [overview]);
|
|
@@ -183,9 +191,10 @@ function useLunatic(source) {
|
|
|
183
191
|
goToPage: goToPage,
|
|
184
192
|
goNextPage: goNextPage,
|
|
185
193
|
goPreviousPage: goPreviousPage,
|
|
186
|
-
withOverview: withOverview
|
|
194
|
+
withOverview: withOverview,
|
|
195
|
+
workersBasePath: workersBasePath
|
|
187
196
|
}));
|
|
188
|
-
}, [source, data, initialPage, features, preferences, savingType, management, shortcut, handleChange, activeControls, withOverview, goToPage, goNextPage, goPreviousPage, lastReachedPage]);
|
|
197
|
+
}, [source, data, initialPage, features, preferences, savingType, management, shortcut, handleChange, activeControls, withOverview, goToPage, goNextPage, goPreviousPage, lastReachedPage, workersBasePath]);
|
|
189
198
|
(0, _react.useEffect)(function () {
|
|
190
199
|
dispatch(actions.updateState({
|
|
191
200
|
getSuggesterStatus: getSuggesterStatus
|
|
@@ -206,9 +215,7 @@ function useLunatic(source) {
|
|
|
206
215
|
Provider: Provider,
|
|
207
216
|
onChange: handleChange,
|
|
208
217
|
overview: buildedOverview,
|
|
209
|
-
loopVariables: (0, _useLoopVariables.useLoopVariables)(pager, state.pages)
|
|
210
|
-
getChangedData: getChangedData,
|
|
211
|
-
resetChangedData: resetChangedData
|
|
218
|
+
loopVariables: (0, _useLoopVariables.useLoopVariables)(pager, state.pages)
|
|
212
219
|
};
|
|
213
220
|
}
|
|
214
221
|
var _default = useLunatic;
|