@inseefr/lunatic 2.6.5 → 2.6.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.
@@ -19,8 +19,7 @@ function ListResponses(_ref) {
19
19
  });
20
20
  }
21
21
  function Responses(_ref2) {
22
- var values = _ref2.values,
23
- sectionIndex = _ref2.sectionIndex;
22
+ var values = _ref2.values;
24
23
  if (!values) {
25
24
  return null;
26
25
  }
@@ -31,7 +30,7 @@ function Responses(_ref2) {
31
30
  id = _ref3.id;
32
31
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)("li", {
33
32
  children: [label, " : ", value]
34
- }, "".concat(id, "-").concat(sectionIndex));
33
+ }, "response-".concat(index));
35
34
  })
36
35
  });
37
36
  }
@@ -48,8 +47,7 @@ function SummaryResponses(_ref4) {
48
47
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(ListResponses, {
49
48
  title: title,
50
49
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(Responses, {
51
- values: values,
52
- sectionIndex: index
50
+ values: values
53
51
  })
54
52
  }, "".concat(id, "-").concat(index));
55
53
  })
@@ -3,10 +3,11 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports["default"] = exports.Default = void 0;
6
+ exports["default"] = exports.Loop = exports.Default = void 0;
7
7
  var _react = _interopRequireDefault(require("react"));
8
8
  var _orchestrator = _interopRequireDefault(require("../../utils/orchestrator"));
9
9
  var _source = _interopRequireDefault(require("./source.json"));
10
+ var _sourceLoop = _interopRequireDefault(require("./source-loop.json"));
10
11
  var _defaultArgTypes = _interopRequireDefault(require("../../utils/default-arg-types"));
11
12
  var _jsxRuntime = require("react/jsx-runtime");
12
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -79,6 +80,13 @@ var Template = function Template(args) {
79
80
  var Default = Template.bind({});
80
81
  exports.Default = Default;
81
82
  Default.args = {
82
- id: 'resizing-default',
83
+ id: 'cleaning-default',
83
84
  pagination: true
85
+ };
86
+ var Loop = Template.bind({});
87
+ exports.Loop = Loop;
88
+ Loop.args = {
89
+ id: 'cleaning-loop',
90
+ pagination: true,
91
+ source: _sourceLoop["default"]
84
92
  };
@@ -0,0 +1,130 @@
1
+ {
2
+ "resizing": {
3
+ "PRENOM": {
4
+ "variables": ["AGE", "HIDE_AGE"],
5
+ "size": "count(PRENOM)"
6
+ }
7
+ },
8
+ "cleaning": {
9
+ "HIDE_AGE": {
10
+ "AGE": "false"
11
+ }
12
+ },
13
+ "variables": [
14
+ {
15
+ "variableType": "COLLECTED",
16
+ "values": {
17
+ "COLLECTED": ["John", "Jane"],
18
+ "EDITED": null,
19
+ "INPUTED": null,
20
+ "FORCED": null,
21
+ "PREVIOUS": null
22
+ },
23
+ "name": "PRENOM"
24
+ },
25
+ {
26
+ "variableType": "COLLECTED",
27
+ "values": {
28
+ "COLLECTED": [null],
29
+ "EDITED": null,
30
+ "INPUTED": null,
31
+ "FORCED": null,
32
+ "PREVIOUS": null
33
+ },
34
+ "name": "AGE"
35
+ },
36
+ {
37
+ "variableType": "COLLECTED",
38
+ "values": {
39
+ "COLLECTED": [null],
40
+ "EDITED": null,
41
+ "INPUTED": null,
42
+ "FORCED": null,
43
+ "PREVIOUS": null
44
+ },
45
+ "name": "HIDE_AGE"
46
+ }
47
+ ],
48
+ "components": [
49
+ {
50
+ "componentType": "Loop",
51
+ "id": "loop",
52
+ "label": "Ajouter",
53
+ "bindingDependencies": ["PRENOM"],
54
+ "lines": {
55
+ "min": { "value": 1, "type": "VTL" },
56
+ "max": { "value": 10, "type": "VTL" }
57
+ },
58
+ "page": "1",
59
+ "components": [
60
+ {
61
+ "componentType": "Input",
62
+ "label": "Prénom",
63
+ "bindingDependencies": ["PRENOM"],
64
+ "id": "prenom",
65
+ "response": {
66
+ "name": "PRENOM"
67
+ }
68
+ }
69
+ ]
70
+ },
71
+ {
72
+ "componentType": "Loop",
73
+ "id": "loop2",
74
+ "paginatedLoop": true,
75
+ "bindingDependencies": ["PRENOM"],
76
+ "iterations": { "value": "count(PRENOM)", "type": "VTL" },
77
+ "page": "2",
78
+ "maxPage": "2",
79
+ "components": [
80
+ {
81
+ "componentType": "Input",
82
+ "label": {
83
+ "value": "\"Age de \" || PRENOM",
84
+ "type": "VTL"
85
+ },
86
+ "bindingDependencies": ["AGE"],
87
+ "id": "age",
88
+ "page": "2.1",
89
+ "response": {
90
+ "name": "AGE"
91
+ }
92
+ },
93
+ {
94
+ "componentType": "CheckboxBoolean",
95
+ "label": {
96
+ "value": "\"Masquer l'age de \" || PRENOM || \" ?\"",
97
+ "type": "VTL"
98
+ },
99
+ "bindingDependencies": ["HIDE_AGE"],
100
+ "id": "hideage",
101
+ "page": "2.2",
102
+ "response": {
103
+ "name": "HIDE_AGE"
104
+ }
105
+ }
106
+ ]
107
+ },
108
+ {
109
+ "componentType": "Sequence",
110
+ "conditionFilter": {
111
+ "type": "VTL",
112
+ "value": "true"
113
+ },
114
+ "id": "ksyjs7vy",
115
+ "page": "3",
116
+ "label": {
117
+ "type": "VTL|MD",
118
+ "value": "\"END\""
119
+ }
120
+ }
121
+ ],
122
+ "pagination": "question",
123
+ "lunaticModelVersion": "2.3.2-rc4",
124
+ "modele": "TESTSURSUM",
125
+ "enoCoreVersion": "2.4.1-pairwise",
126
+ "generatingDate": "14-04-2023 09:00:09",
127
+ "missing": false,
128
+ "id": "lb3ei722",
129
+ "maxPage": "3"
130
+ }
@@ -65,7 +65,7 @@ function cleanedValue(variable, iteration) {
65
65
  var _variable$variable$va;
66
66
  initialValue = (_variable$variable$va = variable.variable.values.COLLECTED) !== null && _variable$variable$va !== void 0 ? _variable$variable$va : null;
67
67
  }
68
- if (!iteration || !Array.isArray(variable.value)) {
68
+ if (iteration === undefined || !Array.isArray(variable.value)) {
69
69
  return initialValue;
70
70
  }
71
71
 
@@ -8,6 +8,7 @@ var _source2 = _interopRequireDefault(require("../stories/questionnaires/logemen
8
8
  var _source3 = _interopRequireDefault(require("../stories/questionnaires/simpsons/source.json"));
9
9
  var _source4 = _interopRequireDefault(require("../stories/component-set/source.json"));
10
10
  var _source5 = _interopRequireDefault(require("../stories/behaviour/cleaning/source.json"));
11
+ var _sourceLoop = _interopRequireDefault(require("../stories/behaviour/cleaning/source-loop.json"));
11
12
  var _sourceResizingCleaning = _interopRequireDefault(require("../stories/behaviour/resizing/source-resizing-cleaning.json"));
12
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
14
  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); }
@@ -206,6 +207,35 @@ var dataFromObject = function dataFromObject(o) {
206
207
  });
207
208
  (0, _vitest.expect)(spy.mock.calls[2][1]).toEqual('US');
208
209
  });
210
+ (0, _vitest.it)('should handle cleaning in a loop', function () {
211
+ var _renderHook11 = (0, _reactHooks.renderHook)(function () {
212
+ return (0, _useLunatic["default"])(_sourceLoop["default"], undefined, {});
213
+ }),
214
+ result = _renderHook11.result;
215
+ (0, _reactHooks.act)(function () {
216
+ result.current.onChange({
217
+ name: 'PRENOM'
218
+ }, ['John', 'Doe', 'Marc']);
219
+ result.current.onChange({
220
+ name: 'AGE'
221
+ }, [18, 18, 18]);
222
+ // Go in the first iteration
223
+ result.current.goNextPage();
224
+ result.current.goNextPage();
225
+ });
226
+ var expectCollectedAgeToEqual = function expectCollectedAgeToEqual(expectation) {
227
+ (0, _vitest.expect)(result.current.getData(false).COLLECTED.AGE.COLLECTED).toEqual(expectation);
228
+ };
229
+ expectCollectedAgeToEqual([18, 18, 18]);
230
+ (0, _reactHooks.act)(function () {
231
+ result.current.onChange({
232
+ name: 'HIDE_AGE'
233
+ }, true, {
234
+ iteration: 0
235
+ });
236
+ });
237
+ expectCollectedAgeToEqual([null, 18, 18]);
238
+ });
209
239
  });
210
240
  (0, _vitest.describe)('resizing', function () {
211
241
  var expectValueForResponse = function expectValueForResponse(spy, responseName, expectedValue) {
@@ -217,12 +247,12 @@ var dataFromObject = function dataFromObject(o) {
217
247
  };
218
248
  (0, _vitest.it)('should resize after cleaning', function () {
219
249
  var spy = _vitest.vi.fn();
220
- var _renderHook11 = (0, _reactHooks.renderHook)(function () {
250
+ var _renderHook12 = (0, _reactHooks.renderHook)(function () {
221
251
  return (0, _useLunatic["default"])(_sourceResizingCleaning["default"], undefined, {
222
252
  onChange: spy
223
253
  });
224
254
  }),
225
- result = _renderHook11.result;
255
+ result = _renderHook12.result;
226
256
  result.current.onChange({
227
257
  name: 'NB'
228
258
  }, 3);
@@ -235,10 +265,10 @@ var dataFromObject = function dataFromObject(o) {
235
265
  });
236
266
  (0, _vitest.describe)('getComponents()', function () {
237
267
  (0, _vitest.describe)('componentSet', function () {
238
- var _renderHook12 = (0, _reactHooks.renderHook)(function () {
268
+ var _renderHook13 = (0, _reactHooks.renderHook)(function () {
239
269
  return (0, _useLunatic["default"])(_source4["default"], undefined, {});
240
270
  }),
241
- result = _renderHook12.result;
271
+ result = _renderHook13.result;
242
272
  var getComponents = function getComponents() {
243
273
  return result.current.getComponents();
244
274
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inseefr/lunatic",
3
- "version": "2.6.5",
3
+ "version": "2.6.6",
4
4
  "workersVersion": "0.3.0-experimental",
5
5
  "description": "Library of questionnaire components",
6
6
  "repository": {