@inseefr/lunatic 2.7.13 → 2.7.14

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.
@@ -115,6 +115,7 @@ var RosterForLoop = exports.RosterForLoop = (0, _commons.createCustomizableLunat
115
115
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_lunaticComponents.LunaticComponents, {
116
116
  blocklist: _constant.blockedInLoopComponents,
117
117
  components: components,
118
+ memo: true,
118
119
  componentProps: function componentProps(c) {
119
120
  return _objectSpread(_objectSpread(_objectSpread({}, otherProps), c), {}, {
120
121
  id: "".concat(c.id, "-").concat(n)
@@ -26,6 +26,7 @@ function LunaticComponents(_ref) {
26
26
  autoFocusKey = _ref.autoFocusKey,
27
27
  componentProps = _ref.componentProps,
28
28
  blocklist = _ref.blocklist,
29
+ memo = _ref.memo,
29
30
  _ref$wrapper = _ref.wrapper,
30
31
  wrapper = _ref$wrapper === void 0 ? function (_ref2) {
31
32
  var children = _ref2.children;
@@ -58,7 +59,7 @@ function LunaticComponents(_ref) {
58
59
  var _props = _objectSpread(_objectSpread({}, component), componentProps === null || componentProps === void 0 ? void 0 : componentProps(component));
59
60
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Fragment, {
60
61
  children: wrapper(_objectSpread({
61
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(LunaticComponent, _objectSpread({}, _props)),
62
+ children: memo ? /*#__PURE__*/(0, _jsxRuntime.jsx)(LunaticComponentMemo, _objectSpread({}, _props)) : /*#__PURE__*/(0, _jsxRuntime.jsx)(LunaticComponent, _objectSpread({}, _props)),
62
63
  index: k
63
64
  }, _props))
64
65
  }, computeId(component, k));
@@ -92,6 +93,7 @@ function LunaticComponent(props) {
92
93
  var Component = lunaticComponents[props.componentType];
93
94
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, _objectSpread({}, props));
94
95
  }
96
+ var LunaticComponentMemo = /*#__PURE__*/(0, _react.memo)(LunaticComponent);
95
97
  function computeId(component, fallback) {
96
98
  if ('id' in component && typeof component.id === 'string') {
97
99
  return component.id;
@@ -5,6 +5,7 @@ type Props<T extends FilledLunaticComponentProps, V = undefined> = {
5
5
  label: string;
6
6
  [key: string]: unknown;
7
7
  })[];
8
+ memo?: boolean;
8
9
  autoFocusKey?: string;
9
10
  componentProps?: (component: FilledLunaticComponentProps) => V;
10
11
  blocklist?: string[];
@@ -15,7 +16,7 @@ type Props<T extends FilledLunaticComponentProps, V = undefined> = {
15
16
  /**
16
17
  * Entry point for orchestrators, this component display the list of fields
17
18
  */
18
- export declare function LunaticComponents<T extends FilledLunaticComponentProps, V = undefined>({ components, autoFocusKey, componentProps, blocklist, wrapper, }: Props<T, V>): import("react/jsx-runtime").JSX.Element;
19
+ export declare function LunaticComponents<T extends FilledLunaticComponentProps, V = undefined>({ components, autoFocusKey, componentProps, blocklist, memo, wrapper, }: Props<T, V>): import("react/jsx-runtime").JSX.Element;
19
20
  export declare function hasLabel(component: unknown): component is {
20
21
  label: ReactNode;
21
22
  } & FilledLunaticComponentProps;
@@ -1,3 +1,2 @@
1
1
  export { default as resizeArrayVariable } from './resize-array-variable';
2
- export { isLoopComponent } from './is-loop-component';
3
2
  export * from './validate-condition-filter';
@@ -0,0 +1,47 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports["default"] = exports.Default = void 0;
7
+ var _react = _interopRequireDefault(require("react"));
8
+ var _orchestrator = _interopRequireDefault(require("../../utils/orchestrator"));
9
+ var _source = _interopRequireDefault(require("./source.json"));
10
+ var _lunatic = require("../../../../tests/utils/lunatic");
11
+ var _array = require("../../../utils/array");
12
+ var _jsxRuntime = require("react/jsx-runtime");
13
+ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14
+ 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); }
15
+ 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; }
16
+ 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; }
17
+ 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; }
18
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
19
+ 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); }
20
+ var stories = {
21
+ title: 'Behaviour/Performance',
22
+ component: _orchestrator["default"]
23
+ };
24
+ var _default = exports["default"] = stories;
25
+ var Template = function Template(args) {
26
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_orchestrator["default"], _objectSpread({}, args));
27
+ };
28
+ var Default = exports.Default = Template.bind({});
29
+ Default.args = {
30
+ id: 'performance-default',
31
+ pagination: true,
32
+ source: _source["default"],
33
+ data: (0, _lunatic.generateData)({
34
+ PRENOM: (0, _array.times)(200, function (k) {
35
+ return "John".concat(k);
36
+ }),
37
+ NOM: (0, _array.times)(200, function (k) {
38
+ return "Doe".concat(k);
39
+ }),
40
+ AGE: (0, _array.times)(200, function (k) {
41
+ return k + 1;
42
+ }),
43
+ BIRTHDAY: (0, _array.times)(200, function (k) {
44
+ return "2".concat(k.toString().padStart(3, '0'), "-01-01");
45
+ })
46
+ })
47
+ };
@@ -0,0 +1,172 @@
1
+ {
2
+ "maxPage": "3",
3
+ "components": [
4
+ {
5
+ "id": "seq",
6
+ "componentType": "Sequence",
7
+ "label": {
8
+ "value": "\"Description des individus de votre logement\"",
9
+ "type": "VTL|MD"
10
+ },
11
+ "conditionFilter": { "value": "true", "type": "VTL" },
12
+ "page": "1"
13
+ },
14
+ {
15
+ "id": "loop-prenom",
16
+ "componentType": "RosterForLoop",
17
+ "header": [
18
+ { "headerCell": true, "label": "Prénom" },
19
+ { "headerCell": true, "label": "Nom" },
20
+ { "headerCell": true, "label": "Date de naissance" },
21
+ { "headerCell": true, "label": "Age" }
22
+ ],
23
+ "label": { "value": "\"Ajouter un individu\"", "type": "VTL|MD" },
24
+ "conditionFilter": { "value": "true", "type": "VTL" },
25
+ "bindingDependencies": ["PRENOM", "AGE"],
26
+ "lines": {
27
+ "min": { "value": 1, "type": "VTL" },
28
+ "max": { "value": 250, "type": "VTL" }
29
+ },
30
+ "page": "1",
31
+ "components": [
32
+ {
33
+ "componentType": "Input",
34
+ "conditionFilter": { "value": "true", "type": "VTL" },
35
+ "maxLength": 30,
36
+ "bindingDependencies": ["PRENOM"],
37
+ "id": "prenom",
38
+ "response": {
39
+ "name": "PRENOM"
40
+ }
41
+ },
42
+ {
43
+ "componentType": "Input",
44
+ "conditionFilter": { "value": "true", "type": "VTL" },
45
+ "maxLength": 30,
46
+ "bindingDependencies": ["NOM"],
47
+ "id": "nom",
48
+ "response": {
49
+ "name": "NOM"
50
+ }
51
+ },
52
+ {
53
+ "componentType": "Datepicker",
54
+ "conditionFilter": { "value": "true", "type": "VTL" },
55
+ "maxLength": 30,
56
+ "bindingDependencies": ["BIRTHDAY"],
57
+ "id": "birthday",
58
+ "dateFormat": "YYYY-MM-DD",
59
+ "response": {
60
+ "name": "BIRTHDAY"
61
+ }
62
+ },
63
+ {
64
+ "componentType": "Input",
65
+ "conditionFilter": { "value": "true", "type": "VTL" },
66
+ "maxLength": 30,
67
+ "bindingDependencies": ["AGE"],
68
+ "id": "age",
69
+ "response": {
70
+ "name": "AGE"
71
+ }
72
+ }
73
+ ]
74
+ },
75
+ {
76
+ "id": "loop",
77
+ "componentType": "Loop",
78
+
79
+ "loopDependencies": ["PRENOM"],
80
+ "iterations": { "value": "count(PRENOM)", "type": "VTL" },
81
+ "page": "2",
82
+ "maxPage": "1",
83
+ "depth": 1,
84
+ "paginatedLoop": true,
85
+ "conditionFilter": {
86
+ "value": "true",
87
+ "type": "VTL"
88
+ },
89
+ "components": [
90
+ {
91
+ "id": "age",
92
+ "label": {
93
+ "value": "PRENOM || \", quel est vôtre âge ?\"",
94
+ "type": "VTL"
95
+ },
96
+ "conditionFilter": {
97
+ "value": "true",
98
+ "type": "VTL"
99
+ },
100
+ "page": "2.1",
101
+ "componentType": "InputNumber",
102
+ "min": 0,
103
+ "max": 120,
104
+ "decimals": 0,
105
+ "response": { "name": "AGE" }
106
+ }
107
+ ]
108
+ },
109
+ {
110
+ "id": "seq-end",
111
+ "componentType": "Sequence",
112
+ "label": {
113
+ "value": "\"End\"",
114
+ "type": "VTL|MD"
115
+ },
116
+ "conditionFilter": { "value": "true", "type": "VTL" },
117
+ "page": "3"
118
+ }
119
+ ],
120
+ "resizing": {
121
+ "PRENOM": {
122
+ "size": "count(PRENOM)",
123
+ "variables": ["AGE"]
124
+ }
125
+ },
126
+ "variables": [
127
+ {
128
+ "variableType": "COLLECTED",
129
+ "name": "PRENOM",
130
+ "values": {
131
+ "PREVIOUS": [null],
132
+ "COLLECTED": [null],
133
+ "FORCED": [null],
134
+ "EDITED": [null],
135
+ "INPUTED": [null]
136
+ }
137
+ },
138
+ {
139
+ "variableType": "COLLECTED",
140
+ "name": "NOM",
141
+ "values": {
142
+ "PREVIOUS": [null],
143
+ "COLLECTED": [null],
144
+ "FORCED": [null],
145
+ "EDITED": [null],
146
+ "INPUTED": [null]
147
+ }
148
+ },
149
+ {
150
+ "variableType": "COLLECTED",
151
+ "name": "BIRTHDAY",
152
+ "values": {
153
+ "PREVIOUS": [null],
154
+ "COLLECTED": [null],
155
+ "FORCED": [null],
156
+ "EDITED": [null],
157
+ "INPUTED": [null]
158
+ }
159
+ },
160
+ {
161
+ "variableType": "COLLECTED",
162
+ "name": "AGE",
163
+ "values": {
164
+ "PREVIOUS": [null],
165
+ "COLLECTED": [null],
166
+ "FORCED": [null],
167
+ "EDITED": [null],
168
+ "INPUTED": [null]
169
+ }
170
+ }
171
+ ]
172
+ }
@@ -204,7 +204,8 @@ function OrchestratorForStories(_ref3) {
204
204
  overview = _lunatic$useLunatic.overview,
205
205
  compileControls = _lunatic$useLunatic.compileControls,
206
206
  getData = _lunatic$useLunatic.getData,
207
- Provider = _lunatic$useLunatic.Provider;
207
+ Provider = _lunatic$useLunatic.Provider,
208
+ hasPageResponse = _lunatic$useLunatic.hasPageResponse;
208
209
  var components = getComponents();
209
210
  var lastReachedPage = pager.lastReachedPage;
210
211
  var _useState3 = (0, _react.useState)({}),
@@ -286,6 +287,17 @@ function OrchestratorForStories(_ref3) {
286
287
  maxPage: maxPage,
287
288
  getData: getData,
288
289
  pager: pager
290
+ }), /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
291
+ className: "story-pager",
292
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("h3", {
293
+ children: "Misc"
294
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)("ul", {
295
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("li", {
296
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("strong", {
297
+ children: "pageHasResponse:"
298
+ }), ' ', JSON.stringify(hasPageResponse())]
299
+ })
300
+ })]
289
301
  }), showOverview && /*#__PURE__*/(0, _jsxRuntime.jsx)(_overview.Overview, {
290
302
  overview: overview,
291
303
  goToPage: goToPage
@@ -1,11 +1,9 @@
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); }
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.compileControls = compileControls;
8
- var _commons = require("../reducer/commons");
9
7
  var _replaceComponentSequence = require("../replace-component-sequence");
10
8
  var _typeSource = require("../type-source");
11
9
  var _fillComponentExpressions = _interopRequireDefault(require("./fill-components/fill-component-expressions"));
@@ -13,6 +11,7 @@ var _getComponentsFromState = _interopRequireDefault(require("./get-components-f
13
11
  var _checkRoundaboutControl = require("../reducer/controls/check-roundabout-control");
14
12
  var _checkBaseControl = require("../reducer/controls/check-base-control");
15
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
14
+ 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
15
  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
16
  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
17
  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; }
@@ -21,6 +20,10 @@ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input ==
21
20
  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
21
  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
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; }
23
+ var isLoopComponent = function isLoopComponent(component) {
24
+ return ['Loop', 'RosterForLoop'].includes(component.componentType);
25
+ };
26
+
24
27
  /**
25
28
  * Check if components of the current page have errors, and return a map of error (indexed by component ID)
26
29
  */
@@ -33,6 +36,7 @@ function checkComponents(state, components) {
33
36
  var component = _step.value;
34
37
  var controls = component.controls,
35
38
  id = component.id;
39
+
36
40
  // The component has global level controls
37
41
  if (Array.isArray(controls)) {
38
42
  var componentErrors = checkControls(controls.filter(function (c) {
@@ -44,7 +48,7 @@ function checkComponents(state, components) {
44
48
  }
45
49
 
46
50
  // For loop, inspect children
47
- if ((0, _commons.isLoopComponent)(component)) {
51
+ if (isLoopComponent(component)) {
48
52
  var _component$controls;
49
53
  var rowControls = (_component$controls = component.controls) === null || _component$controls === void 0 ? void 0 : _component$controls.filter(function (c) {
50
54
  return c.type === _typeSource.ControlTypeEnum.row;
@@ -92,7 +96,7 @@ function checkControls(controls, executeExpression, pager) {
92
96
  * Figure out the number of iterations of a component
93
97
  */
94
98
  function computeIterations(component, executeExpression) {
95
- if ('iterations' in component) {
99
+ if ('iterations' in component && component.iterations && _typeof(component.iterations) === 'object' && 'value' in component.iterations) {
96
100
  return executeExpression(component.iterations.value);
97
101
  }
98
102
  if ('response' in component) {
@@ -127,7 +131,9 @@ function checkComponentInLoop(state, component, errors) {
127
131
  nbIterations: iterations
128
132
  });
129
133
  // The component is filtered on this iteration, skip it
130
- if (component.conditionFilter && !state.executeExpression(component.conditionFilter.value, iterationPager)) {
134
+ if (
135
+ // conditionFilter can be the interpreted expression, or the object representing the expression
136
+ _typeof(component.conditionFilter) == 'object' && !state.executeExpression(component.conditionFilter.value, iterationPager) || component.conditionFilter === false) {
131
137
  continue;
132
138
  }
133
139
  var componentErrors = checkControls(component.controls, state.executeExpression, iterationPager);
@@ -59,11 +59,7 @@ function fillChildComponentsWithIteration(component, state) {
59
59
  return _objectSpread(_objectSpread({}, component), {}, {
60
60
  getComponents: function getComponents(iteration) {
61
61
  return (0, _fillComponents["default"])(component.components, _objectSpread(_objectSpread({}, state), {}, {
62
- handleChange: function handleChange(response, value) {
63
- state.handleChange(response, value, {
64
- iteration: [iteration]
65
- });
66
- },
62
+ handleChange: createChangeHandlerForIteration(state.handleChange, iteration),
67
63
  pager: _objectSpread(_objectSpread({}, state.pager), {}, {
68
64
  iteration: iteration,
69
65
  subPage: 0 // Fake a subpage to simulate an iteration
@@ -73,6 +69,27 @@ function fillChildComponentsWithIteration(component, state) {
73
69
  });
74
70
  }
75
71
 
72
+ // Create change handler memoized for every iteration
73
+ var changeHandler = null;
74
+ var changeHandlerMap = new Map();
75
+ function createChangeHandlerForIteration(handleChange, iteration) {
76
+ if (handleChange !== changeHandler) {
77
+ changeHandler = handleChange;
78
+ changeHandlerMap.clear();
79
+ }
80
+ var handler = changeHandlerMap.get(iteration);
81
+ if (handler) {
82
+ return handler;
83
+ }
84
+ handler = function handler(response, value) {
85
+ handleChange(response, value, {
86
+ iteration: [iteration]
87
+ });
88
+ };
89
+ changeHandlerMap.set(iteration, handler);
90
+ return handler;
91
+ }
92
+
76
93
  /**
77
94
  * For pairwise, inject a method to retrieve component at a specific iteration combination
78
95
  */
@@ -260,6 +260,11 @@ var LunaticVariable = /*#__PURE__*/function () {
260
260
 
261
261
  // Calculate bindings first to refresh "updatedAt" on calculated dependencies
262
262
  var bindings = this.getDependenciesValues(iteration);
263
+ // A variable without binding is a primitive (string, boolean...)
264
+ // it yields the same results for every iteration, so we can ignore iteration
265
+ if (Object.keys(bindings).length === 0) {
266
+ iteration = undefined;
267
+ }
263
268
  if (!this.isOutdated(iteration)) {
264
269
  return this.getSavedValue(iteration);
265
270
  }
@@ -212,6 +212,16 @@ var _lunaticVariablesStore = require("./lunatic-variables-store");
212
212
  (0, _vitest.expect)(variables.get('AGE', [1])).toEqual(12);
213
213
  (0, _vitest.expect)(variables.get('AGE_AND_MAX', [0])).toEqual(13);
214
214
  });
215
+ (0, _vitest.it)('should handle primitive value', function () {
216
+ variables.run('"hello"', {
217
+ iteration: [0]
218
+ });
219
+ variables.run('"hello"', {
220
+ iteration: [1]
221
+ });
222
+ (0, _vitest.expect)(variables.run('"hello"')).toEqual('hello');
223
+ (0, _vitest.expect)(variables.interpretCount).toBe(1);
224
+ });
215
225
  });
216
226
  (0, _vitest.describe)('resizing', function () {
217
227
  (0, _vitest.it)('should resize variables', function () {
@@ -19,8 +19,8 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
19
19
  */
20
20
  function usePageHasResponse(components, executeExpression) {
21
21
  return (0, _react.useCallback)(function () {
22
- if (!Array.isArray(components)) {
23
- return false;
22
+ if (!Array.isArray(components) || components.length === 0) {
23
+ return true;
24
24
  }
25
25
  var _iterator = _createForOfIteratorHelper(components),
26
26
  _step;
@@ -28,9 +28,16 @@ function usePageHasResponse(components, executeExpression) {
28
28
  for (_iterator.s(); !(_step = _iterator.n()).done;) {
29
29
  var component = _step.value;
30
30
  // Some components are considered as "filled" by default
31
- if (['PairwiseLinks', 'Roundabout'].includes(component.componentType)) {
31
+ // We assume they are not in the same page has other components
32
+ if (['PairwiseLinks', 'Roundabout', 'Sequence', 'Subsequence'].includes(component.componentType)) {
32
33
  return true;
33
34
  }
35
+
36
+ // We have a missing response for this component
37
+ if ('missingResponse' in component && component.missingResponse && component.missingResponse.value) {
38
+ return true;
39
+ }
40
+
34
41
  // For Table, we have to extract components from its body and apply isSubComponentsEmpty function
35
42
  if (component.componentType === 'Table') {
36
43
  // Body is array for array (row), each "cell" could be an Label or Component, so we filter array.
@@ -47,6 +54,7 @@ function usePageHasResponse(components, executeExpression) {
47
54
  if ('value' in component && !isEmpty(component.value)) {
48
55
  return true;
49
56
  }
57
+
50
58
  // For rosterForLoop we need to inspect child components
51
59
  if ('components' in component && Array.isArray(component.components) && !isSubComponentsEmpty(component.components, executeExpression)) {
52
60
  return true;
@@ -4,15 +4,8 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  var _exportNames = {
7
- resizeArrayVariable: true,
8
- isLoopComponent: true
7
+ resizeArrayVariable: true
9
8
  };
10
- Object.defineProperty(exports, "isLoopComponent", {
11
- enumerable: true,
12
- get: function get() {
13
- return _isLoopComponent.isLoopComponent;
14
- }
15
- });
16
9
  Object.defineProperty(exports, "resizeArrayVariable", {
17
10
  enumerable: true,
18
11
  get: function get() {
@@ -20,7 +13,6 @@ Object.defineProperty(exports, "resizeArrayVariable", {
20
13
  }
21
14
  });
22
15
  var _resizeArrayVariable = _interopRequireDefault(require("./resize-array-variable"));
23
- var _isLoopComponent = require("./is-loop-component");
24
16
  var _validateConditionFilter = require("./validate-condition-filter");
25
17
  Object.keys(_validateConditionFilter).forEach(function (key) {
26
18
  if (key === "default" || key === "__esModule") return;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inseefr/lunatic",
3
- "version": "2.7.13",
3
+ "version": "2.7.14",
4
4
  "workersVersion": "0.3.0",
5
5
  "description": "Library of questionnaire components",
6
6
  "repository": {
@@ -1,10 +0,0 @@
1
- import type { LunaticComponentDefinition } from '../../type';
2
- export declare const isLoopComponent: (component: LunaticComponentDefinition) => component is (import("../../type-source").ComponentTypeBase & import("../../type-source").ComponentRosterForLoopType & {
3
- componentType: "CheckboxOne" | "ConfirmationModal" | "Sequence" | "Subsequence" | "RosterForLoop" | "Loop" | "Table" | "InputNumber" | "Datepicker" | "CheckboxGroup" | "CheckboxBoolean" | "Radio" | "FilterDescription" | "Dropdown" | "PairwiseLinks" | "Roundabout" | "Suggester" | "Input" | "Textarea" | "ComponentSet" | "QuestionExplication";
4
- } & {
5
- componentType: 'Loop' | 'RosterForLoop';
6
- }) | (import("../../type-source").ComponentTypeBase & import("../../type-source").ComponentLoopType & {
7
- componentType: "CheckboxOne" | "ConfirmationModal" | "Sequence" | "Subsequence" | "RosterForLoop" | "Loop" | "Table" | "InputNumber" | "Datepicker" | "CheckboxGroup" | "CheckboxBoolean" | "Radio" | "FilterDescription" | "Dropdown" | "PairwiseLinks" | "Roundabout" | "Suggester" | "Input" | "Textarea" | "ComponentSet" | "QuestionExplication";
8
- } & {
9
- componentType: 'Loop' | 'RosterForLoop';
10
- });
@@ -1,9 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.isLoopComponent = void 0;
7
- var isLoopComponent = exports.isLoopComponent = function isLoopComponent(component) {
8
- return ['Loop', 'RosterForLoop'].includes(component.componentType);
9
- };