@inseefr/lunatic 2.7.4 → 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.
Files changed (102) hide show
  1. package/README.fr.md +1 -1
  2. package/README.md +6 -1
  3. package/lib/components/commons/components/md-label/link.js +39 -34
  4. package/lib/components/commons/components/md-label/md-label.js +2 -2
  5. package/lib/components/commons/components/md-label/md-label.spec.js +71 -0
  6. package/lib/components/commons/components/md-label/router-link.js +29 -0
  7. package/lib/components/commons/components/variable-status/variable-status.js +2 -2
  8. package/lib/components/index.scss +19 -1
  9. package/lib/components/loop/block-for-loop.js +2 -0
  10. package/lib/components/loop/constant.js +10 -0
  11. package/lib/components/loop/roster-for-loop/roster-for-loop.js +42 -20
  12. package/lib/components/lunatic-components.js +45 -7
  13. package/lib/components/table/lunatic-table.js +5 -1
  14. package/lib/hooks/use-auto-focus.js +1 -1
  15. package/lib/src/components/commons/components/md-label/router-link.d.ts +6 -0
  16. package/lib/src/components/datepicker/lunatic-datepicker.d.ts +1 -1
  17. package/lib/src/components/loop/constant.d.ts +4 -0
  18. package/lib/src/components/loop/roster-for-loop/roster-for-loop.d.ts +1 -0
  19. package/lib/src/components/lunatic-components.d.ts +12 -5
  20. package/lib/src/components/type.d.ts +4 -1
  21. package/lib/src/use-lunatic/commons/compile-controls.d.ts +4 -3
  22. package/lib/src/use-lunatic/commons/fill-components/fill-component-required.d.ts +75 -70
  23. package/lib/src/use-lunatic/commons/fill-components/fill-from-state.d.ts +55 -50
  24. package/lib/src/use-lunatic/commons/fill-components/fill-iterations.d.ts +31 -26
  25. package/lib/src/use-lunatic/commons/fill-components/fill-specific-expression.d.ts +680 -73
  26. package/lib/src/use-lunatic/commons/use-components-from-state.d.ts +1 -1
  27. package/lib/src/use-lunatic/commons/variables/lunatic-variables-store.d.ts +1 -0
  28. package/lib/src/use-lunatic/hooks/use-page-has-response.d.ts +6 -0
  29. package/lib/src/use-lunatic/reducer/commons/is-loop-component.d.ts +2 -2
  30. package/lib/src/use-lunatic/reducer/controls/check-base-control.d.ts +2 -0
  31. package/lib/src/use-lunatic/reducer/{resolve-component-controls/resolve-roundabout-control.d.ts → controls/check-roundabout-control.d.ts} +2 -2
  32. package/lib/src/use-lunatic/type-source.d.ts +16 -10
  33. package/lib/src/use-lunatic/use-lunatic.d.ts +12 -5
  34. package/lib/src/utils/suggester-workers/searching/meloto-order.d.ts +2 -1
  35. package/lib/stories/behaviour/controls/controls.stories.js +14 -7
  36. package/lib/stories/behaviour/controls/loop.json +130 -0
  37. package/lib/stories/behaviour/controls/{V2_ControlesNonNum_horsBoucle_PasPageFin.json → simple.json} +2 -2
  38. package/lib/stories/date-picker/source.json +22 -67
  39. package/lib/stories/declaration/source.json +14 -28
  40. package/lib/stories/dropdown/source.json +11 -28
  41. package/lib/stories/filter-description/source.json +3 -2
  42. package/lib/stories/input/input.stories.js +1 -8
  43. package/lib/stories/input/source.json +1 -63
  44. package/lib/stories/input-number/input-number.stories.js +2 -22
  45. package/lib/stories/input-number/source.json +4 -6
  46. package/lib/stories/loop/{block-for-loop.stories.js → loop.stories.js} +10 -8
  47. package/lib/stories/loop/roster-for-loop.stories.js +8 -2
  48. package/lib/stories/loop/source-bloc.json +10 -39
  49. package/lib/stories/loop/source-paginated.json +65 -78
  50. package/lib/stories/{loop/paginated-loop.stories.js → markdown/markdown.stories.js} +4 -4
  51. package/lib/stories/markdown/source.json +40 -0
  52. package/lib/stories/overview/overview.stories.js +1 -1
  53. package/lib/stories/pairwise/pairwise-links.stories.js +4 -4
  54. package/lib/stories/pairwise/{links.json → source.json} +2 -6
  55. package/lib/stories/question-context/question-context.stories.js +31 -0
  56. package/lib/stories/question-context/source.json +13 -0
  57. package/lib/stories/question-explication/source.json +1 -1
  58. package/lib/stories/{loop/not-paginated-loop.stories.js → question-information/question-information.stories.js} +5 -8
  59. package/lib/stories/question-information/source.json +14 -0
  60. package/lib/stories/roundabout/source.json +21 -31
  61. package/lib/stories/sequence/sequence.stories.js +7 -1
  62. package/lib/stories/sequence/source.json +17 -0
  63. package/lib/stories/suggester/simple.json +1 -1
  64. package/lib/stories/suggester/suggester-workers.stories.js +36 -1
  65. package/lib/stories/table/source-colspan.json +314 -0
  66. package/lib/stories/table/table.stories.js +7 -1
  67. package/lib/stories/textarea/source.json +6 -22
  68. package/lib/stories/utils/orchestrator.js +89 -49
  69. package/lib/stories/utils/orchestrator.scss +49 -0
  70. package/lib/stories/utils/referentiel.js +8 -4
  71. package/lib/use-lunatic/commons/compile-controls.js +135 -34
  72. package/lib/use-lunatic/commons/fill-components/fill-component-value.js +10 -0
  73. package/lib/use-lunatic/commons/fill-components/fill-specific-expression.js +4 -1
  74. package/lib/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js +14 -9
  75. package/lib/use-lunatic/commons/variables/get-questionnaire-data.js +6 -1
  76. package/lib/use-lunatic/commons/variables/lunatic-variables-store.js +25 -7
  77. package/lib/use-lunatic/commons/variables/lunatic-variables-store.spec.js +39 -0
  78. package/lib/use-lunatic/hooks/use-page-has-response.js +104 -0
  79. package/lib/use-lunatic/reducer/{resolve-component-controls/resolve-simple-control.js → controls/check-base-control.js} +5 -7
  80. package/lib/use-lunatic/reducer/{resolve-component-controls/resolve-roundabout-control.js → controls/check-roundabout-control.js} +2 -3
  81. package/lib/use-lunatic/reducer/overview/overview-on-init.js +6 -4
  82. package/lib/use-lunatic/type-source.js +1 -0
  83. package/lib/use-lunatic/use-lunatic.js +3 -1
  84. package/lib/utils/env.js +1 -1
  85. package/lib/utils/suggester-workers/searching/meloto-order.js +6 -5
  86. package/package.json +2 -2
  87. package/workers-release/lunatic-search-worker-0.3.0.js +1 -1
  88. package/lib/src/use-lunatic/commons/get-errors-without-empty-value.d.ts +0 -6
  89. package/lib/src/use-lunatic/reducer/resolve-component-controls/index.d.ts +0 -1
  90. package/lib/src/use-lunatic/reducer/resolve-component-controls/resolve-component-control.d.ts +0 -6
  91. package/lib/src/use-lunatic/reducer/resolve-component-controls/resolve-simple-control.d.ts +0 -3
  92. package/lib/stories/Introduction.stories.mdx +0 -112
  93. package/lib/stories/behaviour/controls/V2_Controles_BouclesLiees_PasPageFin.json +0 -533
  94. package/lib/stories/input/source-with-question.json +0 -80
  95. package/lib/stories/input-number/source-euros.json +0 -37
  96. package/lib/stories/input-number/source-thansand.json +0 -34
  97. package/lib/stories/loop/source-not-paginated.json +0 -138
  98. package/lib/use-lunatic/commons/get-errors-without-empty-value.js +0 -24
  99. package/lib/use-lunatic/reducer/resolve-component-controls/index.js +0 -12
  100. package/lib/use-lunatic/reducer/resolve-component-controls/resolve-component-control.js +0 -38
  101. /package/lib/stories/behaviour/controls/{V2_ControlesNum_horsBoucle_PasPageFin.json → simple-numeric.json} +0 -0
  102. /package/lib/stories/pairwise/{links-componentset.json → source-componentset.json} +0 -0
@@ -1,80 +0,0 @@
1
- {
2
- "components": [
3
- {
4
- "componentType": "QuestionInformation",
5
- "label": { "value": "\"Question Information\"", "type": "VTL|MD" },
6
- "description": {
7
- "value": "\"Question Information description\"",
8
- "type": "VTL|MD"
9
- },
10
- "page": "1"
11
- },
12
- {
13
- "componentType": "Input",
14
- "label": {
15
- "value": "\"Prénom de l'occupant principal.\"",
16
- "type": "VTL|MD"
17
- },
18
- "conditionFilter": { "value": "true", "type": "VTL" },
19
- "maxLength": 30,
20
- "id": "name",
21
- "response": {
22
- "name": "PRENOM"
23
- },
24
- "page": "1"
25
- },
26
- {
27
- "componentType": "QuestionContext",
28
- "label": { "value": "\"Question Context\"", "type": "VTL|MD" },
29
- "description": {
30
- "value": "\"Question Context description\"",
31
- "type": "VTL|MD"
32
- },
33
- "page": "1"
34
- },
35
- {
36
- "componentType": "Input",
37
- "label": {
38
- "value": "\"Nom de l'occupant principal.\"",
39
- "type": "VTL|MD"
40
- },
41
- "conditionFilter": { "value": "true", "type": "VTL" },
42
- "maxLength": 30,
43
- "id": "surname",
44
- "description": {
45
- "value": "\"For example, Bob.\"",
46
- "type": "VTL|MD"
47
- },
48
- "response": {
49
- "name": "NOM"
50
- },
51
- "page": "1"
52
- }
53
- ],
54
- "variables": [
55
- {
56
- "variableType": "COLLECTED",
57
- "name": "NOM",
58
- "componentRef": "name",
59
- "values": {
60
- "PREVIOUS": null,
61
- "COLLECTED": null,
62
- "FORCED": null,
63
- "EDITED": null,
64
- "INPUTED": null
65
- }
66
- },
67
- {
68
- "variableType": "COLLECTED",
69
- "name": "PRENOM",
70
- "componentRef": "name",
71
- "values": {
72
- "PREVIOUS": null,
73
- "COLLECTED": null,
74
- "FORCED": null,
75
- "EDITED": null,
76
- "INPUTED": null
77
- }
78
- }
79
- ]
80
- }
@@ -1,37 +0,0 @@
1
- {
2
- "components": [
3
- {
4
- "id": "kze792d8",
5
- "componentType": "InputNumber",
6
- "mandatory": false,
7
- "page": "2",
8
- "min": 0,
9
- "max": 10,
10
- "decimals": 0,
11
- "label": { "value": "\"➡ 1. \" || \"NB \"", "type": "VTL|MD" },
12
- "conditionFilter": { "value": "true", "type": "VTL" },
13
- "hierarchy": {
14
- "sequence": {
15
- "id": "ksyjs7vy",
16
- "page": "1",
17
- "label": { "value": "S0", "type": "VTL|MD" }
18
- }
19
- },
20
- "bindingDependencies": ["NB"],
21
- "response": { "name": "NB" }
22
- }
23
- ],
24
- "variables": [
25
- {
26
- "variableType": "COLLECTED",
27
- "name": "NB",
28
- "values": {
29
- "PREVIOUS": null,
30
- "COLLECTED": null,
31
- "FORCED": null,
32
- "EDITED": null,
33
- "INPUTED": null
34
- }
35
- }
36
- ]
37
- }
@@ -1,34 +0,0 @@
1
- {
2
- "components": [
3
- {
4
- "id": "kze792d8",
5
- "componentType": "InputNumber",
6
- "mandatory": false,
7
- "page": "2",
8
- "label": { "value": "\"➡ 1. \" || \"Big number \"", "type": "VTL|MD" },
9
- "conditionFilter": { "value": "true", "type": "VTL" },
10
- "hierarchy": {
11
- "sequence": {
12
- "id": "ksyjs7vy",
13
- "page": "1",
14
- "label": { "value": "S0", "type": "VTL|MD" }
15
- }
16
- },
17
- "bindingDependencies": ["NB"],
18
- "response": { "name": "NB" }
19
- }
20
- ],
21
- "variables": [
22
- {
23
- "variableType": "COLLECTED",
24
- "name": "NB",
25
- "values": {
26
- "PREVIOUS": null,
27
- "COLLECTED": null,
28
- "FORCED": null,
29
- "EDITED": null,
30
- "INPUTED": null
31
- }
32
- }
33
- ]
34
- }
@@ -1,138 +0,0 @@
1
- {
2
- "enoCoreVersion": "2.4.1",
3
- "lunaticModelVersion": "2.3.1",
4
- "pagination": "question",
5
- "maxPage": "4",
6
- "label": {
7
- "value": "\"Test Sympa\"",
8
- "type": "VTL|MD"
9
- },
10
- "suggesters": [
11
- {
12
- "name": "cog-communes",
13
- "fields": [
14
- { "name": "label", "rules": "soft" },
15
- { "name": "nccenr", "rules": "soft" },
16
- { "name": "id", "rules": "soft" }
17
- ],
18
- "queryParser": { "type": "soft" },
19
- "version": "1"
20
- }
21
- ],
22
- "components": [
23
- {
24
- "id": "nn",
25
- "componentType": "InputNumber",
26
- "mandatory": false,
27
- "min": 1,
28
- "max": 4,
29
- "decimals": 0,
30
- "label": { "value": "\"Number of inhabitants\"", "type": "VTL|MD" },
31
- "conditionFilter": { "value": "true", "type": "VTL" },
32
- "response": {
33
- "name": "NUM"
34
- },
35
- "page": "1"
36
- },
37
- {
38
- "id": "idLoop",
39
- "label": { "value": "\"Boucle individu\"", "type": "VTL|MD" },
40
- "componentType": "Loop",
41
- "iterations": { "value": "cast(NUM, integer)", "type": "VTL" },
42
- "paginatedLoop": false,
43
- "conditionFilter": { "value": "true", "type": "VTL" },
44
- "loopDependencies": ["NUM"],
45
- "page": "2",
46
- "components": [
47
- {
48
- "id": "k3ym6x16",
49
- "label": { "value": "\"Prénom :\"", "type": "VTL|MD" },
50
- "componentType": "Input",
51
- "conditionFilter": { "value": "true", "type": "VTL" },
52
- "mandatory": false,
53
- "response": {
54
- "name": "PRENOM"
55
- },
56
- "page": "2"
57
- }
58
- ]
59
- },
60
- {
61
- "id": "idLoopInd",
62
- "label": { "value": "\"Boucle individu\"", "type": "VTL|MD" },
63
- "componentType": "Loop",
64
- "iterations": { "value": "count(PRENOM)", "type": "VTL" },
65
- "paginatedLoop": true,
66
- "conditionFilter": { "value": "true", "type": "VTL" },
67
- "loopDependencies": ["PRENOM"],
68
- "page": "3",
69
- "maxPage": "1",
70
- "depth": 1,
71
- "components": [
72
- {
73
- "id": "sugg-communes",
74
- "componentType": "Suggester",
75
- "mandatory": false,
76
- "label": {
77
- "value": "PRENOM || \" what's your favorite city?\"",
78
- "type": "VTL|MD"
79
- },
80
- "storeName": "cog-communes",
81
- "conditionFilter": {
82
- "value": "not(isnull(PRENOM))",
83
- "type": "VTL"
84
- },
85
- "response": {
86
- "name": "CITY"
87
- },
88
- "page": "3.1"
89
- }
90
- ]
91
- },
92
- {
93
- "id": "kk",
94
- "componentType": "Sequence",
95
- "label": { "value": "\"END\"", "type": "VTL|MD" },
96
- "conditionFilter": { "value": "true", "type": "VTL" },
97
- "page": "4"
98
- }
99
- ],
100
- "variables": [
101
- {
102
- "variableType": "COLLECTED",
103
- "name": "NUM",
104
- "componentRef": "nn",
105
- "values": {
106
- "PREVIOUS": null,
107
- "COLLECTED": null,
108
- "FORCED": null,
109
- "EDITED": null,
110
- "INPUTED": null
111
- }
112
- },
113
- {
114
- "variableType": "COLLECTED",
115
- "name": "PRENOM",
116
- "componentRef": "idLoop",
117
- "values": {
118
- "PREVIOUS": [null],
119
- "COLLECTED": [null],
120
- "FORCED": [null],
121
- "EDITED": [null],
122
- "INPUTED": [null]
123
- }
124
- },
125
- {
126
- "variableType": "COLLECTED",
127
- "name": "CITY",
128
- "componentRef": "idLoopInd",
129
- "values": {
130
- "PREVIOUS": [null],
131
- "COLLECTED": [null],
132
- "FORCED": [null],
133
- "EDITED": [null],
134
- "INPUTED": [null]
135
- }
136
- }
137
- ]
138
- }
@@ -1,24 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports["default"] = void 0;
7
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
8
- 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."); }
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; }
11
- function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
12
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
13
- /**
14
- * Keep errors with at least one error inside
15
- */
16
- function getErrorsWithoutEmptyValue(errors) {
17
- return errors ? Object.fromEntries(Object.entries(errors).filter(function (_ref) {
18
- var _ref2 = _slicedToArray(_ref, 2),
19
- _ = _ref2[0],
20
- value = _ref2[1];
21
- return Array.isArray(value) && value.length;
22
- })) : {};
23
- }
24
- var _default = exports["default"] = getErrorsWithoutEmptyValue;
@@ -1,12 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- Object.defineProperty(exports, "resolveComponentControls", {
7
- enumerable: true,
8
- get: function get() {
9
- return _resolveComponentControl.resolveComponentControls;
10
- }
11
- });
12
- var _resolveComponentControl = require("./resolve-component-control");
@@ -1,38 +0,0 @@
1
- "use strict";
2
-
3
- Object.defineProperty(exports, "__esModule", {
4
- value: true
5
- });
6
- exports.resolveComponentControls = resolveComponentControls;
7
- var _resolveRoundaboutControl = require("./resolve-roundabout-control");
8
- var _typeSource = require("../../type-source");
9
- var _resolveSimpleControl = require("./resolve-simple-control");
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 _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); }
13
- function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
14
- function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
15
- 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; }
16
- function resolveControl(state, control) {
17
- var type = control.type;
18
- switch (type) {
19
- case _typeSource.ControlTypeEnum.roundabout:
20
- return (0, _resolveRoundaboutControl.resolveRoundaboutControl)(state, control);
21
- case _typeSource.ControlTypeEnum.simple:
22
- default:
23
- return (0, _resolveSimpleControl.resolveSimpleControl)(state, control);
24
- }
25
- }
26
-
27
- /**
28
- * Convert controls into errors
29
- */
30
- function resolveComponentControls(state, controls) {
31
- return controls.reduce(function (errors, control) {
32
- var error = resolveControl(state, control);
33
- if (error) {
34
- return [].concat(_toConsumableArray(errors), [error]);
35
- }
36
- return errors;
37
- }, []);
38
- }