@inseefr/lunatic 2.7.5 → 2.7.6
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.fr.md +1 -1
- package/README.md +6 -1
- package/lib/components/loop/block-for-loop.js +2 -0
- package/lib/components/loop/constant.js +10 -0
- package/lib/components/loop/roster-for-loop/roster-for-loop.js +42 -20
- package/lib/components/lunatic-components.js +45 -7
- package/lib/components/table/lunatic-table.js +5 -1
- package/lib/src/components/datepicker/lunatic-datepicker.d.ts +1 -1
- package/lib/src/components/loop/constant.d.ts +4 -0
- package/lib/src/components/loop/roster-for-loop/roster-for-loop.d.ts +1 -0
- package/lib/src/components/lunatic-components.d.ts +12 -5
- package/lib/src/components/type.d.ts +4 -1
- package/lib/src/use-lunatic/commons/compile-controls.d.ts +4 -3
- package/lib/src/use-lunatic/commons/fill-components/fill-component-required.d.ts +75 -70
- package/lib/src/use-lunatic/commons/fill-components/fill-from-state.d.ts +55 -50
- package/lib/src/use-lunatic/commons/fill-components/fill-iterations.d.ts +31 -26
- package/lib/src/use-lunatic/commons/fill-components/fill-specific-expression.d.ts +680 -73
- package/lib/src/use-lunatic/commons/use-components-from-state.d.ts +1 -1
- package/lib/src/use-lunatic/reducer/commons/is-loop-component.d.ts +2 -2
- package/lib/src/use-lunatic/reducer/controls/check-base-control.d.ts +2 -0
- package/lib/src/use-lunatic/reducer/{resolve-component-controls/resolve-roundabout-control.d.ts → controls/check-roundabout-control.d.ts} +2 -2
- package/lib/src/use-lunatic/type-source.d.ts +16 -10
- package/lib/src/use-lunatic/use-lunatic.d.ts +11 -5
- package/lib/stories/behaviour/controls/controls.stories.js +14 -7
- package/lib/stories/behaviour/controls/loop.json +130 -0
- package/lib/stories/behaviour/controls/{V2_ControlesNonNum_horsBoucle_PasPageFin.json → simple.json} +2 -2
- package/lib/stories/date-picker/source.json +22 -67
- package/lib/stories/declaration/source.json +14 -28
- package/lib/stories/dropdown/source.json +11 -28
- package/lib/stories/filter-description/source.json +3 -2
- package/lib/stories/input/input.stories.js +1 -8
- package/lib/stories/input/source.json +1 -63
- package/lib/stories/input-number/input-number.stories.js +2 -22
- package/lib/stories/input-number/source.json +4 -6
- package/lib/stories/loop/{block-for-loop.stories.js → loop.stories.js} +10 -8
- package/lib/stories/loop/roster-for-loop.stories.js +8 -2
- package/lib/stories/loop/source-bloc.json +10 -39
- package/lib/stories/loop/source-paginated.json +65 -78
- package/lib/stories/overview/overview.stories.js +1 -1
- package/lib/stories/pairwise/pairwise-links.stories.js +4 -4
- package/lib/stories/pairwise/{links.json → source.json} +2 -6
- package/lib/stories/{loop/not-paginated-loop.stories.js → question-context/question-context.stories.js} +5 -9
- package/lib/stories/question-context/source.json +13 -0
- package/lib/stories/question-explication/source.json +1 -1
- package/lib/stories/{loop/paginated-loop.stories.js → question-information/question-information.stories.js} +4 -4
- package/lib/stories/question-information/source.json +14 -0
- package/lib/stories/roundabout/source.json +21 -31
- package/lib/stories/sequence/sequence.stories.js +7 -1
- package/lib/stories/sequence/source.json +17 -0
- package/lib/stories/suggester/simple.json +1 -1
- package/lib/stories/table/source-colspan.json +314 -0
- package/lib/stories/table/table.stories.js +7 -1
- package/lib/stories/textarea/source.json +6 -22
- package/lib/use-lunatic/commons/compile-controls.js +135 -34
- package/lib/use-lunatic/commons/fill-components/fill-component-value.js +10 -0
- package/lib/use-lunatic/commons/fill-components/fill-specific-expression.js +4 -1
- package/lib/use-lunatic/hooks/use-page-has-response.js +17 -0
- package/lib/use-lunatic/reducer/{resolve-component-controls/resolve-simple-control.js → controls/check-base-control.js} +5 -7
- package/lib/use-lunatic/reducer/{resolve-component-controls/resolve-roundabout-control.js → controls/check-roundabout-control.js} +2 -3
- package/lib/use-lunatic/reducer/overview/overview-on-init.js +6 -4
- package/lib/use-lunatic/type-source.js +1 -0
- package/package.json +1 -1
- package/lib/src/use-lunatic/commons/get-errors-without-empty-value.d.ts +0 -6
- package/lib/src/use-lunatic/reducer/resolve-component-controls/index.d.ts +0 -1
- package/lib/src/use-lunatic/reducer/resolve-component-controls/resolve-component-control.d.ts +0 -6
- package/lib/src/use-lunatic/reducer/resolve-component-controls/resolve-simple-control.d.ts +0 -3
- package/lib/stories/Introduction.stories.mdx +0 -112
- package/lib/stories/behaviour/controls/V2_Controles_BouclesLiees_PasPageFin.json +0 -533
- package/lib/stories/input/source-with-question.json +0 -80
- package/lib/stories/input-number/source-euros.json +0 -37
- package/lib/stories/input-number/source-thansand.json +0 -34
- package/lib/stories/loop/source-not-paginated.json +0 -138
- package/lib/use-lunatic/commons/get-errors-without-empty-value.js +0 -24
- package/lib/use-lunatic/reducer/resolve-component-controls/index.js +0 -12
- package/lib/use-lunatic/reducer/resolve-component-controls/resolve-component-control.js +0 -38
- /package/lib/stories/behaviour/controls/{V2_ControlesNum_horsBoucle_PasPageFin.json → simple-numeric.json} +0 -0
- /package/lib/stories/pairwise/{links-componentset.json → source-componentset.json} +0 -0
|
@@ -1,71 +1,172 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
4
|
Object.defineProperty(exports, "__esModule", {
|
|
4
5
|
value: true
|
|
5
6
|
});
|
|
6
7
|
exports.compileControls = compileControls;
|
|
7
8
|
var _commons = require("../reducer/commons");
|
|
8
|
-
var _resolveComponentControls = require("../reducer/resolve-component-controls");
|
|
9
9
|
var _replaceComponentSequence = require("../replace-component-sequence");
|
|
10
10
|
var _typeSource = require("../type-source");
|
|
11
11
|
var _fillComponentExpressions = _interopRequireDefault(require("./fill-components/fill-component-expressions"));
|
|
12
12
|
var _getComponentsFromState = _interopRequireDefault(require("./get-components-from-state"));
|
|
13
|
-
var
|
|
13
|
+
var _checkRoundaboutControl = require("../reducer/controls/check-roundabout-control");
|
|
14
|
+
var _checkBaseControl = require("../reducer/controls/check-base-control");
|
|
14
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
16
16
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
17
17
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
18
18
|
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; }
|
|
19
19
|
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
20
20
|
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); }
|
|
21
|
+
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; } } }; }
|
|
22
|
+
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); }
|
|
23
|
+
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; }
|
|
21
24
|
/**
|
|
22
|
-
* Check if components of current page have errors
|
|
25
|
+
* Check if components of the current page have errors, and return a map of error (indexed by component ID)
|
|
23
26
|
*/
|
|
24
|
-
function
|
|
25
|
-
var
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
var
|
|
31
|
-
var
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
function checkComponents(state, components) {
|
|
28
|
+
var errors = {};
|
|
29
|
+
var _iterator = _createForOfIteratorHelper(components),
|
|
30
|
+
_step;
|
|
31
|
+
try {
|
|
32
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
33
|
+
var component = _step.value;
|
|
34
|
+
var controls = component.controls,
|
|
35
|
+
id = component.id;
|
|
36
|
+
// The component has global level controls
|
|
37
|
+
if (Array.isArray(controls)) {
|
|
38
|
+
var componentErrors = checkControls(controls.filter(function (c) {
|
|
39
|
+
return c.type !== _typeSource.ControlTypeEnum.row;
|
|
40
|
+
}), state.executeExpression, state.pager);
|
|
41
|
+
if (componentErrors.length > 0) {
|
|
42
|
+
errors[id] = componentErrors;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// For loop, inspect children
|
|
47
|
+
if ((0, _commons.isLoopComponent)(component)) {
|
|
48
|
+
var _component$controls;
|
|
49
|
+
var rowControls = (_component$controls = component.controls) === null || _component$controls === void 0 ? void 0 : _component$controls.filter(function (c) {
|
|
50
|
+
return c.type === _typeSource.ControlTypeEnum.row;
|
|
51
|
+
});
|
|
52
|
+
if (rowControls !== null && rowControls !== void 0 && rowControls.length) {
|
|
53
|
+
errors = checkComponentInLoop(state, _objectSpread(_objectSpread({}, component), {}, {
|
|
54
|
+
controls: rowControls
|
|
55
|
+
}), errors);
|
|
56
|
+
}
|
|
57
|
+
var _iterator2 = _createForOfIteratorHelper(component.components),
|
|
58
|
+
_step2;
|
|
59
|
+
try {
|
|
60
|
+
for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
|
|
61
|
+
var child = _step2.value;
|
|
62
|
+
errors = checkComponentInLoop(state, child, errors);
|
|
63
|
+
}
|
|
64
|
+
} catch (err) {
|
|
65
|
+
_iterator2.e(err);
|
|
66
|
+
} finally {
|
|
67
|
+
_iterator2.f();
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
} catch (err) {
|
|
72
|
+
_iterator.e(err);
|
|
73
|
+
} finally {
|
|
74
|
+
_iterator.f();
|
|
75
|
+
}
|
|
76
|
+
return errors;
|
|
77
|
+
}
|
|
78
|
+
function checkControls(controls, executeExpression, pager) {
|
|
79
|
+
return controls.map(function (control) {
|
|
80
|
+
switch (control.type) {
|
|
81
|
+
case _typeSource.ControlTypeEnum.roundabout:
|
|
82
|
+
return (0, _checkRoundaboutControl.checkRoundaboutControl)(control, executeExpression);
|
|
83
|
+
default:
|
|
84
|
+
return (0, _checkBaseControl.checkBaseControl)(control, executeExpression, pager);
|
|
34
85
|
}
|
|
86
|
+
}).filter(function (error) {
|
|
87
|
+
return error !== undefined;
|
|
88
|
+
});
|
|
89
|
+
}
|
|
35
90
|
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
91
|
+
/**
|
|
92
|
+
* Figure out the number of iterations of a component
|
|
93
|
+
*/
|
|
94
|
+
function computeIterations(component, executeExpression) {
|
|
95
|
+
if ('iterations' in component) {
|
|
96
|
+
return executeExpression(component.iterations.value);
|
|
97
|
+
}
|
|
98
|
+
if ('response' in component) {
|
|
99
|
+
var value = executeExpression(component.response.name);
|
|
100
|
+
if (Array.isArray(value)) {
|
|
101
|
+
return value.length;
|
|
41
102
|
}
|
|
42
|
-
|
|
103
|
+
}
|
|
104
|
+
// Look at the first component
|
|
105
|
+
if ('components' in component) {
|
|
106
|
+
return computeIterations(component.components[0], executeExpression);
|
|
107
|
+
}
|
|
108
|
+
return 0;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
/**
|
|
112
|
+
* Check controls on a component for each iteration
|
|
113
|
+
* Errors are returned using a map of id suffixed with the iteration index (ex: {prenom-1: [], prenom-3: []})
|
|
114
|
+
*/
|
|
115
|
+
function checkComponentInLoop(state, component, errors) {
|
|
116
|
+
// The component has no controls, skip it
|
|
117
|
+
if (!Array.isArray(component.controls)) {
|
|
43
118
|
return errors;
|
|
44
|
-
}
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
// Execute control for each iteration
|
|
122
|
+
var iterations = computeIterations(component, state.executeExpression);
|
|
123
|
+
for (var i = 0; i < iterations; i++) {
|
|
124
|
+
// Create a pager representing the iteration we want to check
|
|
125
|
+
var iterationPager = _objectSpread(_objectSpread({}, state.pager), {}, {
|
|
126
|
+
iteration: i,
|
|
127
|
+
nbIterations: iterations
|
|
128
|
+
});
|
|
129
|
+
// The component is filtered on this iteration, skip it
|
|
130
|
+
if (component.conditionFilter && !state.executeExpression(component.conditionFilter.value, iterationPager)) {
|
|
131
|
+
continue;
|
|
132
|
+
}
|
|
133
|
+
var componentErrors = checkControls(component.controls, state.executeExpression, iterationPager);
|
|
134
|
+
if (componentErrors.length > 0) {
|
|
135
|
+
errors["".concat(component.id, "-").concat(i)] = componentErrors;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
return errors;
|
|
45
139
|
}
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
140
|
+
|
|
141
|
+
/**
|
|
142
|
+
* Check if there is a critical error (type: "Error" and criticality: "Format")
|
|
143
|
+
*/
|
|
144
|
+
function hasCriticalError(errors) {
|
|
145
|
+
if (!errors) {
|
|
146
|
+
return false;
|
|
53
147
|
}
|
|
54
|
-
|
|
148
|
+
// Look for at least one critical error in the list
|
|
149
|
+
var criticalError = Object.values(errors).flat().find(function (error) {
|
|
150
|
+
return error.criticality.startsWith(_typeSource.Criticality.ERROR) || error.typeOfControl === _typeSource.TypeOfControl.FORMAT;
|
|
151
|
+
});
|
|
152
|
+
return criticalError !== undefined;
|
|
55
153
|
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Check controls for currently visible components and output errors
|
|
157
|
+
*/
|
|
56
158
|
function compileControls(state) {
|
|
57
159
|
var components = (0, _replaceComponentSequence.replaceComponentSequence)((0, _getComponentsFromState["default"])(state));
|
|
58
160
|
var componentFiltered = components.map(function (component) {
|
|
59
161
|
return (0, _fillComponentExpressions["default"])(component, state);
|
|
60
|
-
}).filter(function (
|
|
61
|
-
var conditionFilter =
|
|
162
|
+
}).filter(function (_ref) {
|
|
163
|
+
var conditionFilter = _ref.conditionFilter;
|
|
62
164
|
return conditionFilter !== null && conditionFilter !== void 0 ? conditionFilter : true;
|
|
63
165
|
});
|
|
64
|
-
var errors =
|
|
166
|
+
var errors = checkComponents(state, componentFiltered);
|
|
65
167
|
var currentErrors = Object.keys(errors).length > 0 ? errors : undefined;
|
|
66
|
-
var isCritical = isCriticalErrors(currentErrors);
|
|
67
168
|
return {
|
|
68
169
|
currentErrors: currentErrors,
|
|
69
|
-
isCritical:
|
|
170
|
+
isCritical: hasCriticalError(currentErrors)
|
|
70
171
|
};
|
|
71
172
|
}
|
|
@@ -32,5 +32,15 @@ function getValueForComponent(component, state) {
|
|
|
32
32
|
if ((0, _component.hasResponse)(component)) {
|
|
33
33
|
return state.variables.get(component.response.name, iteration);
|
|
34
34
|
}
|
|
35
|
+
// For loop, value will be a map of child component values
|
|
36
|
+
if ('components' in component) {
|
|
37
|
+
return Object.fromEntries(component.components.map(function (c) {
|
|
38
|
+
return 'response' in c ? c.response.name : null;
|
|
39
|
+
}).filter(function (name) {
|
|
40
|
+
return name !== null;
|
|
41
|
+
}).map(function (name) {
|
|
42
|
+
return [name, state.variables.get(name)];
|
|
43
|
+
}));
|
|
44
|
+
}
|
|
35
45
|
return null;
|
|
36
46
|
}
|
|
@@ -114,7 +114,10 @@ function fillTable(component, state) {
|
|
|
114
114
|
if ((0, _component.hasComponentType)(component)) {
|
|
115
115
|
return (0, _fillComponents.fillComponent)(component, state);
|
|
116
116
|
}
|
|
117
|
-
|
|
117
|
+
// We can have a non typed component with extra attributes (colspan, rowspan)
|
|
118
|
+
return _objectSpread(_objectSpread({}, component), {}, {
|
|
119
|
+
label: state.executeExpression((0, _vtl.getVTLCompatibleValue)(component.label))
|
|
120
|
+
});
|
|
118
121
|
});
|
|
119
122
|
})
|
|
120
123
|
});
|
|
@@ -5,7 +5,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.usePageHasResponse = usePageHasResponse;
|
|
7
7
|
var _react = require("react");
|
|
8
|
+
var _isObject = require("../../utils/is-object");
|
|
8
9
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
10
|
+
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
11
|
+
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."); }
|
|
12
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
13
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
9
14
|
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; } } }; }
|
|
10
15
|
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); }
|
|
11
16
|
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; }
|
|
@@ -26,6 +31,18 @@ function usePageHasResponse(components, executeExpression) {
|
|
|
26
31
|
if (['PairwiseLinks', 'Roundabout'].includes(component.componentType)) {
|
|
27
32
|
return true;
|
|
28
33
|
}
|
|
34
|
+
// For Table, we have to extract components from its body and apply isSubComponentsEmpty function
|
|
35
|
+
if (component.componentType === 'Table') {
|
|
36
|
+
// Body is array for array (row), each "cell" could be an Label or Component, so we filter array.
|
|
37
|
+
var childrenComponent = component.body.reduce(function (_, row) {
|
|
38
|
+
var componentsInRow = row.filter(function (cell) {
|
|
39
|
+
return (0, _isObject.isObject)(cell) && 'componentType' in cell;
|
|
40
|
+
});
|
|
41
|
+
return [].concat(_toConsumableArray(_), _toConsumableArray(componentsInRow));
|
|
42
|
+
}, []);
|
|
43
|
+
return !isSubComponentsEmpty(childrenComponent, executeExpression);
|
|
44
|
+
}
|
|
45
|
+
|
|
29
46
|
// We found a value in one of the root component
|
|
30
47
|
if ('value' in component && !isEmpty(component.value)) {
|
|
31
48
|
return true;
|
|
@@ -3,13 +3,11 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
7
|
-
function
|
|
8
|
-
var
|
|
9
|
-
var
|
|
10
|
-
|
|
11
|
-
iteration = _ref.iteration,
|
|
12
|
-
linksIterations = _ref.linksIterations;
|
|
6
|
+
exports.checkBaseControl = checkBaseControl;
|
|
7
|
+
function checkBaseControl(control, executeExpression, pager) {
|
|
8
|
+
var _control$control$valu, _control$control;
|
|
9
|
+
var iteration = pager.iteration,
|
|
10
|
+
linksIterations = pager.linksIterations;
|
|
13
11
|
var criticality = control.criticality,
|
|
14
12
|
errorMessage = control.errorMessage,
|
|
15
13
|
id = control.id,
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.
|
|
6
|
+
exports.checkRoundaboutControl = checkRoundaboutControl;
|
|
7
7
|
/**
|
|
8
8
|
* Pour le Roundabout, le controle doit être validé pour chaque itération
|
|
9
9
|
* composants l'unité enquêtée.
|
|
@@ -11,9 +11,8 @@ exports.resolveRoundaboutControl = resolveRoundaboutControl;
|
|
|
11
11
|
* Le rondpoint ne peut pas être placé dans une boucle car l'itération est effacée.
|
|
12
12
|
* TODO intégrer cela dans le cadre de boucle de bloucle.
|
|
13
13
|
*/
|
|
14
|
-
function
|
|
14
|
+
function checkRoundaboutControl(control, executeExpression) {
|
|
15
15
|
var _control$control$valu, _control$control;
|
|
16
|
-
var executeExpression = state.executeExpression;
|
|
17
16
|
var criticality = control.criticality,
|
|
18
17
|
errorMessage = control.errorMessage,
|
|
19
18
|
id = control.id,
|
|
@@ -25,10 +25,12 @@ var isSequence = function isSequence(sourceComponent) {
|
|
|
25
25
|
return sourceComponent.components.length > 0 && 'hierarchy' in sourceComponent.components[0];
|
|
26
26
|
};
|
|
27
27
|
var isSequenceSamePage = function isSequenceSamePage(sourceComponent, page) {
|
|
28
|
-
|
|
28
|
+
var _sourceComponent$comp;
|
|
29
|
+
return ((_sourceComponent$comp = sourceComponent.components[0].hierarchy) === null || _sourceComponent$comp === void 0 ? void 0 : _sourceComponent$comp.sequence.page) === page;
|
|
29
30
|
};
|
|
30
31
|
var isSubsequenceSamePage = function isSubsequenceSamePage(sourceComponent, page) {
|
|
31
|
-
|
|
32
|
+
var _sourceComponent$comp2, _sourceComponent$comp3;
|
|
33
|
+
return ((_sourceComponent$comp2 = sourceComponent.components[0].hierarchy) === null || _sourceComponent$comp2 === void 0 ? void 0 : _sourceComponent$comp2.subSequence) !== undefined && ((_sourceComponent$comp3 = sourceComponent.components[0].hierarchy) === null || _sourceComponent$comp3 === void 0 ? void 0 : _sourceComponent$comp3.subSequence.page) === page;
|
|
32
34
|
};
|
|
33
35
|
var isPageReached = function isPageReached(page, lastReachedPage) {
|
|
34
36
|
return parseInt(page, 10) <= parseInt(lastReachedPage, 10);
|
|
@@ -64,7 +66,7 @@ function getOverview(state) {
|
|
|
64
66
|
var component = _step.value;
|
|
65
67
|
var hierarchy = component.hierarchy,
|
|
66
68
|
conditionFilter = component.conditionFilter;
|
|
67
|
-
if (hierarchy.subSequence) {
|
|
69
|
+
if (hierarchy && hierarchy.subSequence) {
|
|
68
70
|
var _executeExpression, _pager$lastReachedPag;
|
|
69
71
|
overviewEntries.subSequences.push(_objectSpread(_objectSpread({}, hierarchy.subSequence), {}, {
|
|
70
72
|
type: 'subSequence',
|
|
@@ -75,7 +77,7 @@ function getOverview(state) {
|
|
|
75
77
|
evaluatedLabel: executeExpression(hierarchy.subSequence.label),
|
|
76
78
|
children: []
|
|
77
79
|
}));
|
|
78
|
-
} else {
|
|
80
|
+
} else if (hierarchy) {
|
|
79
81
|
var _pager$lastReachedPag2, _executeExpression2;
|
|
80
82
|
overviewEntries.sequences.push(_objectSpread(_objectSpread({}, hierarchy.sequence), {}, {
|
|
81
83
|
type: 'sequence',
|
|
@@ -20,6 +20,7 @@ var TypeOfControl = exports.TypeOfControl = /*#__PURE__*/function (TypeOfControl
|
|
|
20
20
|
}({});
|
|
21
21
|
var ControlTypeEnum = exports.ControlTypeEnum = /*#__PURE__*/function (ControlTypeEnum) {
|
|
22
22
|
ControlTypeEnum["roundabout"] = "roundabout";
|
|
23
|
+
ControlTypeEnum["row"] = "ROW";
|
|
23
24
|
ControlTypeEnum["simple"] = "simple";
|
|
24
25
|
return ControlTypeEnum;
|
|
25
26
|
}({});
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export { resolveComponentControls } from './resolve-component-control';
|
package/lib/src/use-lunatic/reducer/resolve-component-controls/resolve-component-control.d.ts
DELETED
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { type StateForControls } from '../../commons/compile-controls';
|
|
2
|
-
import type { LunaticControl, LunaticError } from '../../type';
|
|
3
|
-
/**
|
|
4
|
-
* Convert controls into errors
|
|
5
|
-
*/
|
|
6
|
-
export declare function resolveComponentControls(state: StateForControls, controls: LunaticControl[]): LunaticError[];
|
|
@@ -1,112 +0,0 @@
|
|
|
1
|
-
import { Meta } from '@storybook/addon-docs';
|
|
2
|
-
import Lunatic from '../../docs/img/lunatic-logo.png';
|
|
3
|
-
import { version } from '../../package.json';
|
|
4
|
-
|
|
5
|
-
<Meta title="Introduction" />
|
|
6
|
-
|
|
7
|
-
<style>
|
|
8
|
-
{`
|
|
9
|
-
.subheading {
|
|
10
|
-
--mediumdark: '#999999';
|
|
11
|
-
font-weight: 900;
|
|
12
|
-
font-size: 13px;
|
|
13
|
-
color: #999;
|
|
14
|
-
letter-spacing: 6px;
|
|
15
|
-
line-height: 24px;
|
|
16
|
-
text-transform: uppercase;
|
|
17
|
-
margin-bottom: 12px;
|
|
18
|
-
margin-top: 40px;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
.link-list {
|
|
22
|
-
display: grid;
|
|
23
|
-
grid-template-columns: 1fr;
|
|
24
|
-
grid-template-rows: 1fr 1fr;
|
|
25
|
-
row-gap: 10px;
|
|
26
|
-
}
|
|
27
|
-
|
|
28
|
-
@media (min-width: 620px) {
|
|
29
|
-
.link-list {
|
|
30
|
-
row-gap: 20px;
|
|
31
|
-
column-gap: 20px;
|
|
32
|
-
grid-template-columns: 1fr 1fr;
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
@media all and (-ms-high-contrast:none) {
|
|
37
|
-
.link-list {
|
|
38
|
-
display: -ms-grid;
|
|
39
|
-
-ms-grid-columns: 1fr 1fr;
|
|
40
|
-
-ms-grid-rows: 1fr 1fr;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
.link-item {
|
|
45
|
-
display: block;
|
|
46
|
-
padding: 20px 30px 20px 15px;
|
|
47
|
-
border: 1px solid #00000010;
|
|
48
|
-
border-radius: 5px;
|
|
49
|
-
transition: background 150ms ease-out, border 150ms ease-out, transform 150ms ease-out;
|
|
50
|
-
color: #333333;
|
|
51
|
-
display: flex;
|
|
52
|
-
align-items: flex-start;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
.link-item:hover {
|
|
56
|
-
border-color: #1EA7FD50;
|
|
57
|
-
transform: translate3d(0, -3px, 0);
|
|
58
|
-
box-shadow: rgba(0, 0, 0, 0.08) 0 3px 10px 0;
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
.link-item:active {
|
|
62
|
-
border-color: #1EA7FD;
|
|
63
|
-
transform: translate3d(0, 0, 0);
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
.link-item strong {
|
|
67
|
-
font-weight: 700;
|
|
68
|
-
display: block;
|
|
69
|
-
margin-bottom: 2px;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
.link-item img {
|
|
73
|
-
height: 40px;
|
|
74
|
-
width: 40px;
|
|
75
|
-
margin-right: 15px;
|
|
76
|
-
flex: none;
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
.link-item span {
|
|
80
|
-
font-size: 14px;
|
|
81
|
-
line-height: 20px;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
.tip {
|
|
85
|
-
display: inline-block;
|
|
86
|
-
border-radius: 1em;
|
|
87
|
-
font-size: 11px;
|
|
88
|
-
line-height: 12px;
|
|
89
|
-
font-weight: 700;
|
|
90
|
-
background: #E7FDD8;
|
|
91
|
-
color: #66BF3C;
|
|
92
|
-
padding: 4px 12px;
|
|
93
|
-
margin-right: 10px;
|
|
94
|
-
vertical-align: top;
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
.tip-wrapper {
|
|
98
|
-
font-size: 13px;
|
|
99
|
-
line-height: 20px;
|
|
100
|
-
margin-top: 40px;
|
|
101
|
-
margin-bottom: 40px;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
.tip-wrapper code {
|
|
105
|
-
font-size: 12px;
|
|
106
|
-
display: inline-block;
|
|
107
|
-
}
|
|
108
|
-
`}
|
|
109
|
-
</style>
|
|
110
|
-
|
|
111
|
-
<h1>Welcome to Lunatic storybook version: {version} </h1>
|
|
112
|
-
<img src={Lunatic} alt="Lunatic logo" />
|