@inseefr/lunatic 0.3.2-experimental → 0.3.6-experimental

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 (101) hide show
  1. package/lib/index.js +38 -82
  2. package/lib/index.js.map +1 -1
  3. package/package.json +2 -2
  4. package/src/components/breadcrumb/component.js +29 -29
  5. package/src/components/button/component.js +53 -53
  6. package/src/components/button/index.js +1 -1
  7. package/src/components/checkbox/index.js +3 -3
  8. package/src/components/datepicker/index.js +1 -1
  9. package/src/components/declarations/index.js +1 -1
  10. package/src/components/declarations/wrappers/input-declarations-wrapper.js +28 -7
  11. package/src/components/declarations/wrappers/list-declarations-wrapper.js +232 -232
  12. package/src/components/dropdown/commons/components/dropdown.js +21 -0
  13. package/src/components/dropdown/dropdown-edit/dropdown-edit.js +4 -1
  14. package/src/components/dropdown/dropdown-simple/dropdown.js +3 -1
  15. package/src/components/filter-description/component.js +42 -42
  16. package/src/components/icon/component.js +33 -33
  17. package/src/components/input/index.js +2 -2
  18. package/src/components/input/input-number.js +2 -1
  19. package/src/components/loop/index.js +1 -1
  20. package/src/components/loop-constructor/wrapper/body-component.js +13 -1
  21. package/src/components/radio/index.js +1 -1
  22. package/src/components/sequence/index.js +1 -1
  23. package/src/components/subsequence/index.js +1 -1
  24. package/src/components/suggester/check-store.js +70 -70
  25. package/src/components/suggester/components/suggester-content.js +42 -42
  26. package/src/components/suggester/components/suggester.js +43 -3
  27. package/src/components/suggester/idb-suggester.js +7 -1
  28. package/src/components/suggester/lunatic-suggester.js +1 -0
  29. package/src/components/suggester/suggester-wrapper.js +6 -0
  30. package/src/components/tooltip/response.js +52 -52
  31. package/src/stories/checkbox-boolean/data-forced.json +48 -48
  32. package/src/stories/icons/icons.stories.js +16 -16
  33. package/src/stories/questionnaire/kish.json +275 -0
  34. package/src/stories/questionnaire/logement-queen.json +23390 -23390
  35. package/src/stories/questionnaire/logement-s2.json +46027 -44536
  36. package/src/stories/questionnaire/questionnaire.stories.js +14 -2
  37. package/src/stories/utils/custom-lunatic.scss +23 -23
  38. package/src/stories/utils/orchestrator-split.js +4 -2
  39. package/src/stories/utils/orchestrator.js +4 -2
  40. package/src/tests/components/breadcrumb.spec.js +13 -13
  41. package/src/tests/components/button.spec.js +11 -11
  42. package/src/tests/components/checkbox-boolean.spec.js +45 -45
  43. package/src/tests/components/checkbox-group.spec.js +53 -53
  44. package/src/tests/components/checkbox-one.spec.js +32 -32
  45. package/src/tests/components/datepicker.spec.js +22 -22
  46. package/src/tests/components/declarations-wrappers/input-declarations-wrapper.spec.js +67 -67
  47. package/src/tests/components/declarations-wrappers/list-declarations-wrapper.spec.js +52 -52
  48. package/src/tests/components/declarations-wrappers/simple-declarations-wrapper.spec.js +21 -21
  49. package/src/tests/components/declarations.spec.js +46 -46
  50. package/src/tests/components/input.spec.js +18 -18
  51. package/src/tests/components/loops/loop-static.json +66 -66
  52. package/src/tests/components/loops/loop.json +258 -258
  53. package/src/tests/components/loops/loop.spec.js +30 -30
  54. package/src/tests/components/loops/roster-for-loop.spec.js +18 -18
  55. package/src/tests/components/progress-bar.spec.js +15 -15
  56. package/src/tests/components/radio.spec.js +27 -27
  57. package/src/tests/components/sequence.spec.js +9 -9
  58. package/src/tests/components/subsequence.spec.js +9 -9
  59. package/src/tests/components/table.spec.js +11 -11
  60. package/src/tests/components/textarea.spec.js +18 -18
  61. package/src/tests/components/tooltip.spec.js +25 -25
  62. package/src/tests/setup/setupTests.js +4 -4
  63. package/src/tests/utils/lib/alphabet.spec.js +36 -36
  64. package/src/tests/utils/lib/array.spec.js +22 -22
  65. package/src/tests/utils/lib/checkbox/group.spec.js +72 -72
  66. package/src/tests/utils/lib/decorator/title-decorator.spec.js +12 -12
  67. package/src/tests/utils/lib/input-number.spec.js +18 -18
  68. package/src/tests/utils/lib/items-positioning.spec.js +17 -17
  69. package/src/tests/utils/lib/label-position.spec.js +22 -22
  70. package/src/tests/utils/lib/loops/bindings.spec.js +75 -75
  71. package/src/tests/utils/lib/loops/shared.spec.js +82 -82
  72. package/src/tests/utils/lib/missing/missing.spec.js +74 -74
  73. package/src/tests/utils/lib/missing/mock.js +137 -137
  74. package/src/tests/utils/lib/pagination/shared.spec.js +42 -42
  75. package/src/tests/utils/lib/responses.spec.js +64 -64
  76. package/src/tests/utils/lib/style.spec.js +26 -26
  77. package/src/tests/utils/lib/tooltip/build-response.spec.js +95 -95
  78. package/src/tests/utils/lib/tooltip/content.spec.js +109 -109
  79. package/src/tests/utils/to-expose/handler/handler.spec.js +94 -94
  80. package/src/tests/utils/to-expose/handler/questionnaire.json +158 -158
  81. package/src/tests/utils/to-expose/handler/results/index.js +6 -6
  82. package/src/tests/utils/to-expose/handler/results/res-double.json +158 -158
  83. package/src/tests/utils/to-expose/handler/results/res-input-collected.json +158 -158
  84. package/src/tests/utils/to-expose/handler/results/res-input-edited.json +158 -158
  85. package/src/tests/utils/to-expose/handler/results/res-loop.json +158 -158
  86. package/src/tests/utils/to-expose/handler/results/res-matrix.json +158 -158
  87. package/src/tests/utils/to-expose/handler/results/res-responses.json +158 -158
  88. package/src/tests/utils/to-expose/hooks/use-lunatic.spec.js +46 -46
  89. package/src/tests/utils/to-expose/init-questionnaire/data.json +12 -12
  90. package/src/tests/utils/to-expose/init-questionnaire/init-questionnaire.spec.js +19 -19
  91. package/src/tests/utils/to-expose/interpret/interpret.spec.js +48 -48
  92. package/src/tests/utils/to-expose/state/questionnaire.json +61 -61
  93. package/src/tests/utils/to-expose/state/results.js +78 -78
  94. package/src/utils/lib/splitting.js +55 -23
  95. package/src/utils/lib/tooltip/build-response.js +41 -41
  96. package/src/utils/store-tools/create/index.js +1 -1
  97. package/src/utils/store-tools/create/update-store-info.js +26 -26
  98. package/src/utils/store-tools/index.js +5 -5
  99. package/src/utils/to-expose/handler.js +12 -14
  100. package/src/utils/to-expose/hooks/lunatic-split.js +44 -27
  101. package/src/utils/to-expose/hooks/lunatic.js +12 -5
@@ -1,158 +1,158 @@
1
- {
2
- "components": [
3
- { "id": "1", "componentType": "Sequence", "depth": 1 },
4
- {
5
- "id": "2",
6
- "componentType": "Input",
7
- "response": {
8
- "name": "inputOk",
9
- "values": {
10
- "PREVIOUS": null,
11
- "COLLECTED": "My input",
12
- "FORCED": null,
13
- "EDITED": null,
14
- "INPUTED": null
15
- }
16
- },
17
- "depth": 1
18
- },
19
- {
20
- "id": "3",
21
- "componentType": "CheckboxGroup",
22
- "responses": [
23
- {
24
- "response": {
25
- "name": "check1",
26
- "values": {
27
- "PREVIOUS": null,
28
- "COLLECTED": true,
29
- "FORCED": null,
30
- "EDITED": null,
31
- "INPUTED": null
32
- }
33
- }
34
- },
35
- {
36
- "response": {
37
- "name": "check2",
38
- "values": {
39
- "PREVIOUS": null,
40
- "COLLECTED": false,
41
- "FORCED": null,
42
- "EDITED": null,
43
- "INPUTED": null
44
- }
45
- }
46
- }
47
- ],
48
- "depth": 1
49
- },
50
- {
51
- "id": "4",
52
- "componentType": "Table",
53
- "cells": [
54
- [
55
- { "label": "label", "depth": 1 },
56
- {
57
- "componentType": "Radio",
58
- "response": {
59
- "name": "table11",
60
- "values": {
61
- "PREVIOUS": null,
62
- "COLLECTED": "1",
63
- "FORCED": null,
64
- "EDITED": null,
65
- "INPUTED": null
66
- }
67
- },
68
- "depth": 1
69
- }
70
- ]
71
- ],
72
- "depth": 1
73
- },
74
- {
75
- "id": "5",
76
- "componentType": "RosterForLoop",
77
- "components": [
78
- {
79
- "componentType": "Input",
80
- "response": {
81
- "name": "Roster",
82
- "values": {
83
- "PREVIOUS": [null],
84
- "COLLECTED": ["ok"],
85
- "FORCED": [null],
86
- "EDITED": [null],
87
- "INPUTED": [null]
88
- }
89
- },
90
- "depth": 2
91
- }
92
- ],
93
- "depth": 1
94
- }
95
- ],
96
- "variables": {
97
- "EXTERNAL": { "VAR_EXTERNAL": "Value VAR_EXTERNAL" },
98
- "CALCULATED": {
99
- "Test": {
100
- "expression": "inputOk || \" ok\"",
101
- "value": "My input ok",
102
- "bindingDependencies": ["inputOk"]
103
- }
104
- },
105
- "COLLECTED": {
106
- "inputOk": {
107
- "componentRef": "2",
108
- "values": {
109
- "PREVIOUS": null,
110
- "COLLECTED": "My input",
111
- "FORCED": null,
112
- "EDITED": null,
113
- "INPUTED": null
114
- }
115
- },
116
- "check1": {
117
- "componentRef": "3",
118
- "values": {
119
- "PREVIOUS": null,
120
- "COLLECTED": true,
121
- "FORCED": null,
122
- "EDITED": null,
123
- "INPUTED": null
124
- }
125
- },
126
- "check2": {
127
- "componentRef": "3",
128
- "values": {
129
- "PREVIOUS": null,
130
- "COLLECTED": false,
131
- "FORCED": null,
132
- "EDITED": null,
133
- "INPUTED": null
134
- }
135
- },
136
- "table11": {
137
- "componentRef": "4",
138
- "values": {
139
- "PREVIOUS": null,
140
- "COLLECTED": "1",
141
- "FORCED": null,
142
- "EDITED": null,
143
- "INPUTED": null
144
- }
145
- },
146
- "Roster": {
147
- "componentRef": "5",
148
- "values": {
149
- "PREVIOUS": [null],
150
- "COLLECTED": ["ok"],
151
- "FORCED": [null],
152
- "EDITED": [null],
153
- "INPUTED": [null]
154
- }
155
- }
156
- }
157
- }
158
- }
1
+ {
2
+ "components": [
3
+ { "id": "1", "componentType": "Sequence", "depth": 1 },
4
+ {
5
+ "id": "2",
6
+ "componentType": "Input",
7
+ "response": {
8
+ "name": "inputOk",
9
+ "values": {
10
+ "PREVIOUS": null,
11
+ "COLLECTED": "My input",
12
+ "FORCED": null,
13
+ "EDITED": null,
14
+ "INPUTED": null
15
+ }
16
+ },
17
+ "depth": 1
18
+ },
19
+ {
20
+ "id": "3",
21
+ "componentType": "CheckboxGroup",
22
+ "responses": [
23
+ {
24
+ "response": {
25
+ "name": "check1",
26
+ "values": {
27
+ "PREVIOUS": null,
28
+ "COLLECTED": true,
29
+ "FORCED": null,
30
+ "EDITED": null,
31
+ "INPUTED": null
32
+ }
33
+ }
34
+ },
35
+ {
36
+ "response": {
37
+ "name": "check2",
38
+ "values": {
39
+ "PREVIOUS": null,
40
+ "COLLECTED": false,
41
+ "FORCED": null,
42
+ "EDITED": null,
43
+ "INPUTED": null
44
+ }
45
+ }
46
+ }
47
+ ],
48
+ "depth": 1
49
+ },
50
+ {
51
+ "id": "4",
52
+ "componentType": "Table",
53
+ "cells": [
54
+ [
55
+ { "label": "label", "depth": 1 },
56
+ {
57
+ "componentType": "Radio",
58
+ "response": {
59
+ "name": "table11",
60
+ "values": {
61
+ "PREVIOUS": null,
62
+ "COLLECTED": "1",
63
+ "FORCED": null,
64
+ "EDITED": null,
65
+ "INPUTED": null
66
+ }
67
+ },
68
+ "depth": 1
69
+ }
70
+ ]
71
+ ],
72
+ "depth": 1
73
+ },
74
+ {
75
+ "id": "5",
76
+ "componentType": "RosterForLoop",
77
+ "components": [
78
+ {
79
+ "componentType": "Input",
80
+ "response": {
81
+ "name": "Roster",
82
+ "values": {
83
+ "PREVIOUS": [null],
84
+ "COLLECTED": ["ok"],
85
+ "FORCED": [null],
86
+ "EDITED": [null],
87
+ "INPUTED": [null]
88
+ }
89
+ },
90
+ "depth": 2
91
+ }
92
+ ],
93
+ "depth": 1
94
+ }
95
+ ],
96
+ "variables": {
97
+ "EXTERNAL": { "VAR_EXTERNAL": "Value VAR_EXTERNAL" },
98
+ "CALCULATED": {
99
+ "Test": {
100
+ "expression": "inputOk || \" ok\"",
101
+ "value": "My input ok",
102
+ "bindingDependencies": ["inputOk"]
103
+ }
104
+ },
105
+ "COLLECTED": {
106
+ "inputOk": {
107
+ "componentRef": "2",
108
+ "values": {
109
+ "PREVIOUS": null,
110
+ "COLLECTED": "My input",
111
+ "FORCED": null,
112
+ "EDITED": null,
113
+ "INPUTED": null
114
+ }
115
+ },
116
+ "check1": {
117
+ "componentRef": "3",
118
+ "values": {
119
+ "PREVIOUS": null,
120
+ "COLLECTED": true,
121
+ "FORCED": null,
122
+ "EDITED": null,
123
+ "INPUTED": null
124
+ }
125
+ },
126
+ "check2": {
127
+ "componentRef": "3",
128
+ "values": {
129
+ "PREVIOUS": null,
130
+ "COLLECTED": false,
131
+ "FORCED": null,
132
+ "EDITED": null,
133
+ "INPUTED": null
134
+ }
135
+ },
136
+ "table11": {
137
+ "componentRef": "4",
138
+ "values": {
139
+ "PREVIOUS": null,
140
+ "COLLECTED": "1",
141
+ "FORCED": null,
142
+ "EDITED": null,
143
+ "INPUTED": null
144
+ }
145
+ },
146
+ "Roster": {
147
+ "componentRef": "5",
148
+ "values": {
149
+ "PREVIOUS": [null],
150
+ "COLLECTED": ["ok"],
151
+ "FORCED": [null],
152
+ "EDITED": [null],
153
+ "INPUTED": [null]
154
+ }
155
+ }
156
+ }
157
+ }
158
+ }
@@ -1,46 +1,46 @@
1
- import { renderHook, act } from '@testing-library/react-hooks';
2
- import useLunatic from 'utils/to-expose/hooks/lunatic';
3
- import source from '../init-questionnaire/questionnaire';
4
-
5
- describe('useLunatic', () => {
6
- it('with pagination', () => {
7
- const { result } = renderHook(() =>
8
- useLunatic(source, {}, { features: ['VTL', 'MD'], pagination: true })
9
- );
10
- const {
11
- current: {
12
- components,
13
- pagination: { page, goNext, goPrevious },
14
- },
15
- } = result;
16
- expect(components.length).toEqual(2);
17
- expect(page).toEqual('1');
18
-
19
- act(() => {
20
- goNext();
21
- });
22
-
23
- expect(components.length).toEqual(2);
24
- expect(page).toEqual('1');
25
-
26
- act(() => {
27
- goPrevious();
28
- });
29
-
30
- expect(components.length).toEqual(2);
31
- expect(page).toEqual('1');
32
- });
33
- it('with custom props', () => {
34
- renderHook(() =>
35
- useLunatic(
36
- source,
37
- {},
38
- {
39
- management: true,
40
- savingType: 'EDITED',
41
- preferences: ['COLLECTED', 'EDITED'],
42
- }
43
- )
44
- );
45
- });
46
- });
1
+ import { renderHook, act } from '@testing-library/react-hooks';
2
+ import useLunatic from 'utils/to-expose/hooks/lunatic';
3
+ import source from '../init-questionnaire/questionnaire';
4
+
5
+ describe('useLunatic', () => {
6
+ it('with pagination', () => {
7
+ const { result } = renderHook(() =>
8
+ useLunatic(source, {}, { features: ['VTL', 'MD'], pagination: true })
9
+ );
10
+ const {
11
+ current: {
12
+ components,
13
+ pagination: { page, goNext, goPrevious },
14
+ },
15
+ } = result;
16
+ expect(components.length).toEqual(2);
17
+ expect(page).toEqual('1');
18
+
19
+ act(() => {
20
+ goNext();
21
+ });
22
+
23
+ expect(components.length).toEqual(2);
24
+ expect(page).toEqual('1');
25
+
26
+ act(() => {
27
+ goPrevious();
28
+ });
29
+
30
+ expect(components.length).toEqual(2);
31
+ expect(page).toEqual('1');
32
+ });
33
+ it('with custom props', () => {
34
+ renderHook(() =>
35
+ useLunatic(
36
+ source,
37
+ {},
38
+ {
39
+ management: true,
40
+ savingType: 'EDITED',
41
+ preferences: ['COLLECTED', 'EDITED'],
42
+ }
43
+ )
44
+ );
45
+ });
46
+ });
@@ -1,12 +1,12 @@
1
- {
2
- "COLLECTED": {
3
- "inputOk": { "COLLECTED": "Hello" },
4
- "check1": { "COLLECTED": true },
5
- "check2": { "COLLECTED": false, "FORCED": true },
6
- "table11": { "COLLECTED": "1" },
7
- "Roster": { "COLLECTED": ["ok"] }
8
- },
9
- "EXTERNAL": {
10
- "VAR_EXTERNAL": "Value VAR_EXTERNAL"
11
- }
12
- }
1
+ {
2
+ "COLLECTED": {
3
+ "inputOk": { "COLLECTED": "Hello" },
4
+ "check1": { "COLLECTED": true },
5
+ "check2": { "COLLECTED": false, "FORCED": true },
6
+ "table11": { "COLLECTED": "1" },
7
+ "Roster": { "COLLECTED": ["ok"] }
8
+ },
9
+ "EXTERNAL": {
10
+ "VAR_EXTERNAL": "Value VAR_EXTERNAL"
11
+ }
12
+ }
@@ -1,19 +1,19 @@
1
- import * as I from 'utils/to-expose/init-questionnaire';
2
- import questionnaire from './questionnaire';
3
- import data from './data';
4
- import result from './result';
5
-
6
- describe('init-questionnaire', () => {
7
- describe('mergeQuestionnaireAndData', () => {
8
- it('should return default', () => {
9
- expect(I.mergeQuestionnaireAndData()()).toEqual({});
10
- expect(I.mergeQuestionnaireAndData({})({})).toEqual({});
11
- expect(I.mergeQuestionnaireAndData({ components: [] })({})).toEqual({
12
- components: [],
13
- });
14
- });
15
- it('should return filled questionnaire', () => {
16
- expect(I.mergeQuestionnaireAndData(questionnaire)(data)).toEqual(result);
17
- });
18
- });
19
- });
1
+ import * as I from 'utils/to-expose/init-questionnaire';
2
+ import questionnaire from './questionnaire';
3
+ import data from './data';
4
+ import result from './result';
5
+
6
+ describe('init-questionnaire', () => {
7
+ describe('mergeQuestionnaireAndData', () => {
8
+ it('should return default', () => {
9
+ expect(I.mergeQuestionnaireAndData()()).toEqual({});
10
+ expect(I.mergeQuestionnaireAndData({})({})).toEqual({});
11
+ expect(I.mergeQuestionnaireAndData({ components: [] })({})).toEqual({
12
+ components: [],
13
+ });
14
+ });
15
+ it('should return filled questionnaire', () => {
16
+ expect(I.mergeQuestionnaireAndData(questionnaire)(data)).toEqual(result);
17
+ });
18
+ });
19
+ });
@@ -1,48 +1,48 @@
1
- import { interpret } from 'utils/to-expose/interpret';
2
-
3
- describe('interpret', () => {
4
- describe('interpretVTL', () => {
5
- it('should return empty label', () => {
6
- expect(interpret()()()).toEqual('');
7
- });
8
- it('should return empty label', () => {
9
- expect(interpret({})()()).toEqual('');
10
- });
11
- it('should return the same label', () => {
12
- expect(interpret([])({})('label')).toEqual('label');
13
- });
14
- it('should return VTL interpreted label', () => {
15
- expect(interpret(['VTL'])({ NAME: 'Mauro' })('"Hello " || NAME')).toEqual(
16
- 'Hello Mauro'
17
- );
18
- });
19
- it('should return VTL interpreted label with default value', () => {
20
- expect(interpret(['VTL'])({ NAME: null })('"Hello " || NAME')).toEqual(
21
- 'Hello null'
22
- );
23
- });
24
- });
25
- describe('interpretVTLMD', () => {
26
- it('should return empty label', () => {
27
- expect(interpret()()()).toEqual('');
28
- });
29
- it('should return empty label', () => {
30
- expect(interpret({})()()).toEqual('');
31
- });
32
- it('should return the same label', () => {
33
- expect(interpret([])({})('label')).toEqual('label');
34
- });
35
- it('should return VTL interpreted label', () => {
36
- expect(
37
- interpret(['VTL', 'MD'])({ NAME: 'Mauro' })('"Hello " || NAME').props
38
- .source
39
- ).toEqual('Hello Mauro');
40
- });
41
- it('should return VTL interpreted label with default value', () => {
42
- expect(
43
- interpret(['VTL', 'MD'])({ NAME: null })('"Hello " || NAME').props
44
- .source
45
- ).toEqual('Hello null');
46
- });
47
- });
48
- });
1
+ import { interpret } from 'utils/to-expose/interpret';
2
+
3
+ describe('interpret', () => {
4
+ describe('interpretVTL', () => {
5
+ it('should return empty label', () => {
6
+ expect(interpret()()()).toEqual('');
7
+ });
8
+ it('should return empty label', () => {
9
+ expect(interpret({})()()).toEqual('');
10
+ });
11
+ it('should return the same label', () => {
12
+ expect(interpret([])({})('label')).toEqual('label');
13
+ });
14
+ it('should return VTL interpreted label', () => {
15
+ expect(interpret(['VTL'])({ NAME: 'Mauro' })('"Hello " || NAME')).toEqual(
16
+ 'Hello Mauro'
17
+ );
18
+ });
19
+ it('should return VTL interpreted label with default value', () => {
20
+ expect(interpret(['VTL'])({ NAME: null })('"Hello " || NAME')).toEqual(
21
+ 'Hello null'
22
+ );
23
+ });
24
+ });
25
+ describe('interpretVTLMD', () => {
26
+ it('should return empty label', () => {
27
+ expect(interpret()()()).toEqual('');
28
+ });
29
+ it('should return empty label', () => {
30
+ expect(interpret({})()()).toEqual('');
31
+ });
32
+ it('should return the same label', () => {
33
+ expect(interpret([])({})('label')).toEqual('label');
34
+ });
35
+ it('should return VTL interpreted label', () => {
36
+ expect(
37
+ interpret(['VTL', 'MD'])({ NAME: 'Mauro' })('"Hello " || NAME').props
38
+ .source
39
+ ).toEqual('Hello Mauro');
40
+ });
41
+ it('should return VTL interpreted label with default value', () => {
42
+ expect(
43
+ interpret(['VTL', 'MD'])({ NAME: null })('"Hello " || NAME').props
44
+ .source
45
+ ).toEqual('Hello null');
46
+ });
47
+ });
48
+ });