@inseefr/lunatic 3.4.11-rc.0 → 3.5.0-rc.2

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 (111) hide show
  1. package/components/Loop/Loop.js +7 -27
  2. package/components/Loop/Loop.js.map +1 -1
  3. package/components/RosterForLoop/RosterForLoop.js +8 -37
  4. package/components/RosterForLoop/RosterForLoop.js.map +1 -1
  5. package/components/Sequence/Sequence.d.ts +1 -1
  6. package/components/Subsequence/Subsequence.d.ts +1 -1
  7. package/components/library.d.ts +2 -2
  8. package/esm/components/Loop/Loop.js +7 -27
  9. package/esm/components/Loop/Loop.js.map +1 -1
  10. package/esm/components/RosterForLoop/RosterForLoop.js +8 -34
  11. package/esm/components/RosterForLoop/RosterForLoop.js.map +1 -1
  12. package/esm/components/Sequence/Sequence.d.ts +1 -1
  13. package/esm/components/Subsequence/Subsequence.d.ts +1 -1
  14. package/esm/components/library.d.ts +2 -2
  15. package/esm/hooks/useArticulation.d.ts +58 -0
  16. package/esm/hooks/useArticulation.js +81 -0
  17. package/esm/hooks/useArticulation.js.map +1 -0
  18. package/esm/i18n/dictionary.d.ts +0 -8
  19. package/esm/i18n/dictionary.js +0 -5
  20. package/esm/i18n/dictionary.js.map +1 -1
  21. package/esm/i18n/index.d.ts +1 -1
  22. package/esm/index.d.ts +1 -0
  23. package/esm/index.js +1 -0
  24. package/esm/index.js.map +1 -1
  25. package/esm/type.source.js +1 -0
  26. package/esm/type.source.js.map +1 -1
  27. package/esm/use-lunatic/commons/variables/behaviours/resizing-behaviour.js +7 -23
  28. package/esm/use-lunatic/commons/variables/behaviours/resizing-behaviour.js.map +1 -1
  29. package/esm/use-lunatic/commons/variables/lunatic-variables-store.d.ts +1 -3
  30. package/esm/use-lunatic/commons/variables/lunatic-variables-store.js +1 -1
  31. package/esm/use-lunatic/commons/variables/lunatic-variables-store.js.map +1 -1
  32. package/esm/use-lunatic/commons/variables/lunatic-variables-store.spec.js +1 -66
  33. package/esm/use-lunatic/commons/variables/lunatic-variables-store.spec.js.map +1 -1
  34. package/esm/use-lunatic/props/getComponentTypeProps.d.ts +4 -4
  35. package/esm/use-lunatic/reducer/commons/index.d.ts +1 -0
  36. package/esm/use-lunatic/reducer/commons/index.js +1 -0
  37. package/esm/use-lunatic/reducer/commons/index.js.map +1 -1
  38. package/esm/use-lunatic/reducer/commons/resize-array-variable.d.ts +5 -0
  39. package/esm/use-lunatic/reducer/commons/resize-array-variable.js +21 -0
  40. package/esm/use-lunatic/reducer/commons/resize-array-variable.js.map +1 -0
  41. package/esm/use-lunatic/reducer/reducerInitializer.d.ts +2 -2
  42. package/esm/use-lunatic/reducer/reducerInitializer.js +31 -24
  43. package/esm/use-lunatic/reducer/reducerInitializer.js.map +1 -1
  44. package/esm/use-lunatic/type.d.ts +0 -1
  45. package/esm/utils/array.d.ts +0 -4
  46. package/esm/utils/array.js +2 -15
  47. package/esm/utils/array.js.map +1 -1
  48. package/esm/utils/array.spec.js +1 -12
  49. package/esm/utils/array.spec.js.map +1 -1
  50. package/hooks/useArticulation.d.ts +58 -0
  51. package/hooks/useArticulation.js +81 -0
  52. package/hooks/useArticulation.js.map +1 -0
  53. package/i18n/dictionary.d.ts +0 -8
  54. package/i18n/dictionary.js +0 -5
  55. package/i18n/dictionary.js.map +1 -1
  56. package/i18n/index.d.ts +1 -1
  57. package/index.d.ts +1 -0
  58. package/index.js +3 -1
  59. package/index.js.map +1 -1
  60. package/package.json +20 -4
  61. package/src/components/Loop/Loop.tsx +12 -42
  62. package/src/components/RosterForLoop/RosterForLoop.tsx +2 -42
  63. package/src/components/RosterForLoop/__snapshots__/RosterForLoop.spec.tsx.snap +0 -18
  64. package/src/hooks/useArticulation.ts +124 -0
  65. package/src/i18n/dictionary.ts +0 -5
  66. package/src/index.ts +1 -0
  67. package/src/stories/behaviour/articulation/articulation.stories.tsx +105 -0
  68. package/src/stories/behaviour/articulation/roundabout.json +348 -0
  69. package/src/stories/behaviour/performance/performance.stories.jsx +1 -1
  70. package/src/stories/pairwise/data.json +1 -1
  71. package/src/stories/pairwise/source.json +1 -3
  72. package/src/stories/utils/{SchemaValidator.jsx → SchemaValidator.tsx} +1 -1
  73. package/src/stories/utils/{orchestrator.jsx → orchestrator.tsx} +13 -9
  74. package/src/stories/utils/{overview.jsx → overview.tsx} +2 -0
  75. package/src/type.source.ts +1 -0
  76. package/src/use-lunatic/__snapshots__/use-lunatic.test.ts.snap +323 -0
  77. package/src/use-lunatic/commons/variables/behaviours/resizing-behaviour.ts +10 -35
  78. package/src/use-lunatic/commons/variables/lunatic-variables-store.spec.ts +1 -68
  79. package/src/use-lunatic/commons/variables/lunatic-variables-store.ts +2 -4
  80. package/src/use-lunatic/reducer/commons/index.ts +1 -0
  81. package/src/use-lunatic/reducer/commons/resize-array-variable.ts +28 -0
  82. package/src/use-lunatic/reducer/reducerInitializer.tsx +40 -29
  83. package/src/use-lunatic/type.ts +0 -1
  84. package/src/utils/array.spec.ts +1 -18
  85. package/src/utils/array.ts +3 -21
  86. package/tsconfig.build.tsbuildinfo +1 -1
  87. package/type.source.js +1 -0
  88. package/type.source.js.map +1 -1
  89. package/use-lunatic/commons/variables/behaviours/resizing-behaviour.js +6 -22
  90. package/use-lunatic/commons/variables/behaviours/resizing-behaviour.js.map +1 -1
  91. package/use-lunatic/commons/variables/lunatic-variables-store.d.ts +1 -3
  92. package/use-lunatic/commons/variables/lunatic-variables-store.js +1 -1
  93. package/use-lunatic/commons/variables/lunatic-variables-store.js.map +1 -1
  94. package/use-lunatic/commons/variables/lunatic-variables-store.spec.js +1 -66
  95. package/use-lunatic/commons/variables/lunatic-variables-store.spec.js.map +1 -1
  96. package/use-lunatic/props/getComponentTypeProps.d.ts +4 -4
  97. package/use-lunatic/reducer/commons/index.d.ts +1 -0
  98. package/use-lunatic/reducer/commons/index.js +6 -0
  99. package/use-lunatic/reducer/commons/index.js.map +1 -1
  100. package/use-lunatic/reducer/commons/resize-array-variable.d.ts +5 -0
  101. package/use-lunatic/reducer/commons/resize-array-variable.js +23 -0
  102. package/use-lunatic/reducer/commons/resize-array-variable.js.map +1 -0
  103. package/use-lunatic/reducer/reducerInitializer.d.ts +2 -2
  104. package/use-lunatic/reducer/reducerInitializer.js +31 -24
  105. package/use-lunatic/reducer/reducerInitializer.js.map +1 -1
  106. package/use-lunatic/type.d.ts +0 -1
  107. package/utils/array.d.ts +0 -4
  108. package/utils/array.js +2 -16
  109. package/utils/array.js.map +1 -1
  110. package/utils/array.spec.js +0 -11
  111. package/utils/array.spec.js.map +1 -1
@@ -0,0 +1,124 @@
1
+ import type {
2
+ ComponentDefinition,
3
+ ComponentRoundaboutDefinition,
4
+ LunaticSource,
5
+ } from '../type.source';
6
+ import type { LunaticData } from '../use-lunatic/type';
7
+ import { reducerInitializer } from '../use-lunatic/reducer/reducerInitializer';
8
+ import { type ReactNode, useMemo } from 'react';
9
+ import { times } from '../utils/array';
10
+ import { forceInt } from '../utils/number';
11
+
12
+ type ArticulationItem = {
13
+ label: string;
14
+ value: string;
15
+ };
16
+
17
+ type Articulation = {
18
+ source: string;
19
+ items: ArticulationItem[];
20
+ };
21
+
22
+ type Item = {
23
+ cells: {
24
+ label: string;
25
+ value: ReactNode;
26
+ page?: string;
27
+ }[];
28
+ progress: number; // -1: not completed, 0: started, 1: finished
29
+ };
30
+
31
+ /**
32
+ * Hook to get articulation state
33
+ *
34
+ * ## Why this hook
35
+ *
36
+ * The goal of this hook is to provide insights about a roundabout using extra information inserted in the JSON source
37
+ * provided to Lunatic.
38
+ *
39
+ * For instance
40
+ *
41
+ * ```
42
+ * "articulation": {
43
+ * "source": "roundabout",
44
+ * "items": [
45
+ * {
46
+ * "label": "Prénom",
47
+ * "value": "PRENOMS"
48
+ * },
49
+ * {
50
+ * "label": "Sexe",
51
+ * "value": "if SEXE = \"H\" then \"Homme\" else \"Femme\""
52
+ * },
53
+ * {
54
+ * "label": "Age",
55
+ * "value": "cast(AGE, string) || \" ans\""
56
+ * }
57
+ * ]
58
+ * },
59
+ * ```
60
+ *
61
+ * - source is the ID of the roundabout component
62
+ * - items define the field to extract from the roundabout data
63
+ */
64
+ export function useArticulation(
65
+ source: LunaticSource & { articulation: Articulation },
66
+ data: LunaticData
67
+ ): { items: Item[] } {
68
+ const roundabout = useMemo(
69
+ () => findComponentById(source.components, source.articulation.source),
70
+ [source]
71
+ );
72
+ const { variables } = useMemo(
73
+ () => reducerInitializer({ source, data }),
74
+ [source, data]
75
+ );
76
+
77
+ const iterations = useMemo(
78
+ () => forceInt(variables.run(roundabout?.iterations.value ?? '0')),
79
+ // eslint-disable-next-line react-hooks/exhaustive-deps
80
+ [source, data]
81
+ );
82
+
83
+ const rows = useMemo(() => {
84
+ return times(iterations, (k) =>
85
+ source.articulation.items.map((item) => ({
86
+ label: item.label,
87
+ value: variables.run(item.value, { iteration: [k] }) as ReactNode,
88
+ }))
89
+ );
90
+ // eslint-disable-next-line react-hooks/exhaustive-deps
91
+ }, [source, data, iterations, roundabout?.progressVariable]);
92
+
93
+ if (!roundabout) {
94
+ return {
95
+ items: [],
96
+ };
97
+ }
98
+
99
+ return {
100
+ items: rows.map((row, k) => ({
101
+ cells: row,
102
+ progress: forceInt(variables.get(roundabout.progressVariable, [k]) ?? -1),
103
+ page: roundabout.page ? `${roundabout.page}.1#${k + 1}` : '1',
104
+ })),
105
+ };
106
+ }
107
+
108
+ function findComponentById(
109
+ components: ComponentDefinition[],
110
+ id: string
111
+ ): (ComponentRoundaboutDefinition & { page?: string }) | null {
112
+ for (const c of components) {
113
+ if ('id' in c && c.id === id && c.componentType === 'Roundabout') {
114
+ return c;
115
+ }
116
+ if ('components' in c) {
117
+ const child = findComponentById(c.components, id);
118
+ if (child) {
119
+ return child;
120
+ }
121
+ }
122
+ }
123
+ return null;
124
+ }
@@ -1,11 +1,6 @@
1
1
  const dictionary = {
2
2
  DEFAULT_BUTTON_ADD: { fr: 'Ajouter une ligne', en: 'Add row' },
3
3
  DEFAULT_BUTTON_REMOVE: { fr: 'Supprimer une ligne', en: 'Remove row' },
4
- DEFAULT_BUTTON_REMOVE_THAT_ROW: {
5
- fr: 'Supprimer cette ligne',
6
- en: 'Remove that row',
7
- },
8
- ACTION_HEADER: { fr: 'Action', en: 'Action' },
9
4
  MODAL_IGNORE: { fr: 'Poursuivre', en: 'Ignore' },
10
5
  MODAL_CORRECT: { fr: 'Corriger ma réponse', en: 'Correct' },
11
6
  DK: { fr: 'Ne sais pas', en: "Don't know" },
package/src/index.ts CHANGED
@@ -8,6 +8,7 @@ export { Button } from './components/shared/Button/Button';
8
8
 
9
9
  export { LunaticComponents } from './components/LunaticComponents';
10
10
  export { useLunatic } from './use-lunatic/use-lunatic';
11
+ export { useArticulation } from './hooks/useArticulation';
11
12
 
12
13
  export type {
13
14
  LunaticComponentDefinition,
@@ -0,0 +1,105 @@
1
+ import Orchestrator from '../../utils/orchestrator';
2
+ import source from './roundabout.json';
3
+ import type { Meta, StoryObj } from '@storybook/react';
4
+ import { useState } from 'react';
5
+ import { useArticulation } from '../../../hooks/useArticulation';
6
+
7
+ type Source = Parameters<typeof useArticulation>[0];
8
+ type Data = Parameters<typeof useArticulation>[1];
9
+
10
+ type Props = {
11
+ source: Source;
12
+ data: Data;
13
+ };
14
+
15
+ function StoryComponent({ source, data }: Props) {
16
+ const [page, setPage] = useState(null as null | string);
17
+ const gotoNav = () => setPage(null);
18
+ const { items } = useArticulation(source, data);
19
+
20
+ if (page) {
21
+ return (
22
+ <div>
23
+ {page}
24
+ <button onClick={gotoNav}>&lt; Revenir à l'articulation</button>
25
+ {/* eslint-disable-next-line @typescript-eslint/ban-ts-comment */}
26
+ {/*/ @ts-ignore */}
27
+ <Orchestrator source={source} data={data} initialPage={page} />
28
+ </div>
29
+ );
30
+ }
31
+
32
+ const progressLabel = (n: number) => {
33
+ if (n === -1) {
34
+ return 'Commencer';
35
+ }
36
+ if (n === 0) {
37
+ return 'Continuer';
38
+ }
39
+ return 'Complété';
40
+ };
41
+
42
+ return (
43
+ <div>
44
+ <h2>Articulation</h2>
45
+ <table style={{ borderCollapse: 'collapse' }}>
46
+ <thead>
47
+ <tr>
48
+ {items[0].cells.map((cell, k) => (
49
+ <th
50
+ style={{ border: 'solid 1px #00000024', padding: '.5rem 1rem' }}
51
+ key={k}
52
+ >
53
+ {cell.label}
54
+ </th>
55
+ ))}
56
+ <th>Actions</th>
57
+ </tr>
58
+ </thead>
59
+ <tbody>
60
+ {items.map((item, k) => (
61
+ <tr key={k}>
62
+ {item.cells.map((cell, kk) => (
63
+ <td
64
+ key={kk}
65
+ style={{
66
+ border: 'solid 1px #00000024',
67
+ padding: '.5rem 1rem',
68
+ }}
69
+ >
70
+ {cell.value}
71
+ </td>
72
+ ))}
73
+ <td
74
+ style={{
75
+ border: 'solid 1px #00000024',
76
+ padding: '.5rem 1rem',
77
+ }}
78
+ >
79
+ <button onClick={() => console.log('ToDo')}>
80
+ {progressLabel(item.progress)}
81
+ </button>
82
+ </td>
83
+ </tr>
84
+ ))}
85
+ </tbody>
86
+ </table>
87
+ </div>
88
+ );
89
+ }
90
+
91
+ const meta: Meta<typeof StoryComponent> = {
92
+ title: 'Behaviour/Articulation',
93
+ component: StoryComponent,
94
+ };
95
+
96
+ export default meta;
97
+
98
+ type Story = StoryObj<typeof StoryComponent>;
99
+
100
+ export const Basic: Story = {
101
+ args: {
102
+ source: source as Source,
103
+ data: {},
104
+ },
105
+ };
@@ -0,0 +1,348 @@
1
+ {
2
+ "$schema": "../../../../lunatic-schema.json",
3
+ "maxPage": "4",
4
+ "articulation": {
5
+ "source": "roundabout",
6
+ "items": [
7
+ {
8
+ "label": "Prénom",
9
+ "value": "PRENOMS"
10
+ },
11
+ {
12
+ "label": "Sexe",
13
+ "value": "if SEXE = \"H\" then \"Homme\" else \"Femme\""
14
+ },
15
+ {
16
+ "label": "Age",
17
+ "value": "cast(AGE, string) || \" ans\""
18
+ }
19
+ ]
20
+ },
21
+ "components": [
22
+ {
23
+ "id": "how",
24
+ "componentType": "InputNumber",
25
+ "mandatory": false,
26
+ "page": "1",
27
+ "min": 1,
28
+ "max": 10,
29
+ "decimals": 0,
30
+ "label": {
31
+ "value": "\"Combien de personnes vivent habituellement à votre adresse ?\"",
32
+ "type": "VTL|MD"
33
+ },
34
+ "conditionFilter": { "value": "true", "type": "VTL" },
35
+ "response": { "name": "NB_HAB" }
36
+ },
37
+ {
38
+ "id": "loop",
39
+ "componentType": "Loop",
40
+ "page": "2",
41
+ "depth": 1,
42
+ "paginatedLoop": false,
43
+ "conditionFilter": { "value": "true", "type": "VTL" },
44
+ "loopDependencies": ["NHAB"],
45
+ "lines": {
46
+ "min": { "value": "NB_HAB", "type": "VTL" },
47
+ "max": { "value": "NB_HAB", "type": "VTL" }
48
+ },
49
+ "components": [
50
+ {
51
+ "id": "prenom",
52
+ "componentType": "Input",
53
+ "mandatory": false,
54
+ "maxLength": 20,
55
+ "label": {
56
+ "value": "\"Prénom\"))",
57
+ "type": "VTL|MD"
58
+ },
59
+ "conditionFilter": {
60
+ "value": "true",
61
+ "type": "VTL"
62
+ },
63
+ "response": { "name": "PRENOMS" }
64
+ },
65
+ {
66
+ "id": "sexe",
67
+ "componentType": "CheckboxOne",
68
+ "mandatory": false,
69
+ "maxLength": 20,
70
+ "label": {
71
+ "value": "\"Sexe\"",
72
+ "type": "VTL|MD"
73
+ },
74
+ "conditionFilter": {
75
+ "value": "true",
76
+ "type": "VTL"
77
+ },
78
+ "options": [
79
+ {
80
+ "value": "H",
81
+ "label": { "value": "\"Homme\"", "type": "VTL|MD" }
82
+ },
83
+
84
+ {
85
+ "value": "F",
86
+ "label": { "value": "\"Femme\"", "type": "VTL|MD" }
87
+ }
88
+ ],
89
+ "response": { "name": "SEXE" }
90
+ },
91
+ {
92
+ "id": "age",
93
+ "componentType": "InputNumber",
94
+ "maxLength": 3,
95
+ "label": {
96
+ "value": "\"Age\"",
97
+ "type": "VTL|MD"
98
+ },
99
+ "conditionFilter": {
100
+ "value": "true",
101
+ "type": "VTL"
102
+ },
103
+ "response": { "name": "AGE" }
104
+ }
105
+ ]
106
+ },
107
+ {
108
+ "id": "roundabout",
109
+ "componentType": "Roundabout",
110
+ "page": "3",
111
+ "conditionFilter": { "value": "true", "type": "VTL" },
112
+ "iterations": { "value": "NB_HAB", "type": "VTL" },
113
+ "label": { "value": "\"Libellé du rondpoint\"", "type": "VTL" },
114
+ "locked": true,
115
+ "progressVariable": "PROGRESS",
116
+ "item": {
117
+ "label": {
118
+ "value": "\"Questions de \" || PRENOMS",
119
+ "type": "VTL"
120
+ },
121
+ "description": {
122
+ "value": "if AGE > 18 then \"Aller aux question destinées à \" || PRENOMS else PRENOMS || \" n'est pas majeur, il/elle n'a pas à répondre aux questions\"",
123
+ "type": "VTL"
124
+ },
125
+ "disabled": {
126
+ "value": "AGE < 18",
127
+ "type": "VTL"
128
+ }
129
+ },
130
+ "controls": [],
131
+ "components": [
132
+ {
133
+ "id": "radio",
134
+ "componentType": "Radio",
135
+ "mandatory": false,
136
+ "page": "3.1",
137
+ "label": {
138
+ "value": "\"Connaissez-vous le recensement de la population ?\"",
139
+ "type": "VTL|MD"
140
+ },
141
+
142
+ "conditionFilter": { "value": "true", "type": "VTL" },
143
+
144
+ "options": [
145
+ { "value": "1", "label": { "value": "\"oui\"", "type": "VTL|MD" } },
146
+
147
+ { "value": "2", "label": { "value": "\"non\"", "type": "VTL|MD" } }
148
+ ],
149
+ "response": { "name": "KNOWREC" }
150
+ },
151
+ {
152
+ "id": "jsygk7m7",
153
+ "componentType": "Subsequence",
154
+ "page": "3.2",
155
+ "label": {
156
+ "value": "\"Deuxième page de questions pour \"|| PRENOMS",
157
+ "type": "VTL|MD"
158
+ },
159
+ "conditionFilter": { "value": "true", "type": "VTL" }
160
+ },
161
+ {
162
+ "id": "sexe",
163
+ "componentType": "Radio",
164
+ "page": "3.2",
165
+ "label": {
166
+ "value": "\"Sexe\"",
167
+ "type": "VTL"
168
+ },
169
+ "conditionFilter": {
170
+ "value": "true",
171
+ "type": "VTL"
172
+ },
173
+ "options": [
174
+ {
175
+ "value": "1",
176
+ "label": { "value": "\"Homme\"", "type": "VTL|MD" }
177
+ },
178
+ {
179
+ "value": "2",
180
+ "label": { "value": "\"Femme\"", "type": "VTL|MD" }
181
+ }
182
+ ],
183
+ "response": { "name": "SEXE" }
184
+ },
185
+ {
186
+ "id": "jsygk7m7",
187
+ "componentType": "Subsequence",
188
+ "page": "3.3",
189
+ "label": {
190
+ "value": "\"Troisième page de questions \" || PRENOMS",
191
+ "type": "VTL|MD"
192
+ },
193
+ "conditionFilter": { "value": "true", "type": "VTL" }
194
+ },
195
+ {
196
+ "id": "kmno1n7m",
197
+ "componentType": "Input",
198
+ "maxLength": 30,
199
+ "page": "3.3",
200
+ "label": {
201
+ "value": "\"Dites quelque chose.\"))",
202
+ "type": "VTL|MD"
203
+ },
204
+ "conditionFilter": {
205
+ "value": "true",
206
+ "type": "VTL"
207
+ },
208
+ "response": { "name": "SOMETHING" }
209
+ }
210
+ ]
211
+ },
212
+ {
213
+ "id": "seq",
214
+ "componentType": "Sequence",
215
+ "label": {
216
+ "value": "\"Merci !\"",
217
+ "type": "VTL|MD"
218
+ },
219
+ "conditionFilter": { "value": "true", "type": "VTL" },
220
+ "page": "4"
221
+ }
222
+ ],
223
+ "variables": [
224
+ {
225
+ "variableType": "COLLECTED",
226
+ "name": "NB_HAB",
227
+ "values": {
228
+ "PREVIOUS": null,
229
+ "COLLECTED": 2,
230
+ "FORCED": null,
231
+ "EDITED": null,
232
+ "INPUTTED": null
233
+ }
234
+ },
235
+ {
236
+ "variableType": "COLLECTED",
237
+ "name": "SOMETHING",
238
+ "values": {
239
+ "PREVIOUS": [],
240
+ "COLLECTED": [],
241
+ "FORCED": [],
242
+ "EDITED": [],
243
+ "INPUTTED": []
244
+ }
245
+ },
246
+ {
247
+ "variableType": "COLLECTED",
248
+ "name": "SEXE",
249
+ "values": {
250
+ "PREVIOUS": null,
251
+ "COLLECTED": ["H", "F"],
252
+ "FORCED": null,
253
+ "EDITED": null,
254
+ "INPUTTED": null
255
+ }
256
+ },
257
+ {
258
+ "variableType": "COLLECTED",
259
+ "name": "AGE",
260
+ "values": {
261
+ "PREVIOUS": null,
262
+ "COLLECTED": [24, 24],
263
+ "FORCED": null,
264
+ "EDITED": null,
265
+ "INPUTTED": null
266
+ }
267
+ },
268
+ {
269
+ "variableType": "COLLECTED",
270
+ "name": "SEXE",
271
+ "values": {
272
+ "PREVIOUS": [],
273
+ "COLLECTED": [],
274
+ "FORCED": [],
275
+ "EDITED": [],
276
+ "INPUTTED": []
277
+ }
278
+ },
279
+ {
280
+ "variableType": "COLLECTED",
281
+ "name": "PRENOMS",
282
+ "values": {
283
+ "PREVIOUS": null,
284
+ "COLLECTED": ["Fanny", "Ines"],
285
+ "FORCED": null,
286
+ "EDITED": null,
287
+ "INPUTTED": null
288
+ }
289
+ },
290
+ {
291
+ "variableType": "COLLECTED",
292
+ "name": "KNOWREC",
293
+ "values": {
294
+ "PREVIOUS": [],
295
+ "COLLECTED": [],
296
+ "FORCED": [],
297
+ "EDITED": [],
298
+ "INPUTTED": []
299
+ }
300
+ },
301
+ {
302
+ "variableType": "COLLECTED",
303
+ "name": "PROGRESS",
304
+ "values": {
305
+ "PREVIOUS": [],
306
+ "COLLECTED": [0, -1],
307
+ "FORCED": [],
308
+ "EDITED": [],
309
+ "INPUTTED": []
310
+ }
311
+ },
312
+ {
313
+ "variableType": "CALCULATED",
314
+ "name": "PRENOMREF",
315
+ "expression": { "value": "first_value(PRENOMS over())", "type": "VTL" },
316
+ "bindingDependencies": ["PRENOMS"],
317
+ "inFilter": "true"
318
+ },
319
+ {
320
+ "variableType": "CALCULATED",
321
+ "name": "COMPLETE",
322
+ "expression": {
323
+ "value": "not(isnull(KNOWREC)) and not(isnull(SEXE)) and not(isnull(SOMETHING))",
324
+ "type": "VTL"
325
+ },
326
+ "bindingDependencies": ["KNOWREC", "SEXE", "SOMETHING"],
327
+ "shapeFrom": "PRENOMS",
328
+ "inFilter": "true"
329
+ },
330
+ {
331
+ "variableType": "CALCULATED",
332
+ "name": "PARTIAL",
333
+ "expression": {
334
+ "value": "not(isnull(KNOWREC)) or not(isnull(SEXE)) or not(isnull(SOMETHING))",
335
+ "type": "VTL"
336
+ },
337
+ "bindingDependencies": ["KNOWREC", "SEXE", "SOMETHING"],
338
+ "shapeFrom": "PRENOMS",
339
+ "inFilter": "true"
340
+ }
341
+ ],
342
+ "resizing": {
343
+ "NB_HAB": {
344
+ "size": "NB_HAB",
345
+ "variables": ["PRENOMS", "AGE", "SEXE", "SOMETHING", "DATNAIS"]
346
+ }
347
+ }
348
+ }
@@ -1,8 +1,8 @@
1
1
  import React from 'react';
2
- import Orchestrator from '../../utils/orchestrator';
3
2
  import source from './source.json';
4
3
  import { generateData } from '../../../tests/utils/lunatic';
5
4
  import { times } from '../../../utils/array';
5
+ import Orchestrator from '../../utils/orchestrator';
6
6
 
7
7
  const stories = {
8
8
  title: 'Behaviour/Performance',
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "COLLECTED": {
3
- "PRENOM": { "COLLECTED": ["Dad", "Mom", "Daughter"] },
3
+ "PRENOM": { "COLLECTED": ["Dad", "Mom", "Unknow"] },
4
4
  "AGE": { "COLLECTED": [30, 29, 5] },
5
5
  "LINKS": {
6
6
  "COLLECTED": [[null]]
@@ -341,9 +341,7 @@
341
341
  "resizing": {
342
342
  "PRENOM": {
343
343
  "sizeForLinksVariables": ["count(PRENOM)", "count(PRENOM)"],
344
- "linksVariables": ["LINKS"],
345
- "size": "count(PRENOM)",
346
- "variables": ["AGE"]
344
+ "linksVariables": ["LINKS"]
347
345
  }
348
346
  }
349
347
  }
@@ -2,7 +2,7 @@ import Ajv from 'ajv/dist/2020.js';
2
2
  import { useMemo } from 'react';
3
3
  import LunaticSchema from '../../../lunatic-schema.json';
4
4
 
5
- export function SchemaValidator({ source }) {
5
+ export function SchemaValidator({ source }: { source: any }) {
6
6
  const errors = useMemo(() => {
7
7
  const ajv = new Ajv({
8
8
  removeAdditional: true,