@inseefr/lunatic 0.3.4-experimental → 0.3.7-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 (85) hide show
  1. package/lib/index.js +2 -2
  2. package/lib/index.js.map +1 -1
  3. package/package.json +2 -1
  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/list-declarations-wrapper.js +232 -232
  11. package/src/components/filter-description/component.js +42 -42
  12. package/src/components/icon/component.js +33 -33
  13. package/src/components/index.js +2 -0
  14. package/src/components/input/index.js +2 -2
  15. package/src/components/loop/index.js +1 -1
  16. package/src/components/loop-constructor/wrapper/body-component.js +13 -1
  17. package/src/components/radio/index.js +1 -1
  18. package/src/components/sequence/index.js +1 -1
  19. package/src/components/subsequence/index.js +1 -1
  20. package/src/components/suggester/check-store.js +70 -70
  21. package/src/components/suggester/components/create-on-keydown-callback.js +28 -28
  22. package/src/components/tooltip/response.js +52 -52
  23. package/src/stories/checkbox-boolean/data-forced.json +48 -48
  24. package/src/stories/checkbox-group/data-vtl.json +102 -102
  25. package/src/stories/icons/icons.stories.js +16 -16
  26. package/src/stories/questionnaire/kish.json +275 -0
  27. package/src/stories/questionnaire/questionnaire.stories.js +12 -0
  28. package/src/stories/utils/custom-lunatic.scss +23 -23
  29. package/src/tests/components/breadcrumb.spec.js +13 -13
  30. package/src/tests/components/button.spec.js +11 -11
  31. package/src/tests/components/checkbox-boolean.spec.js +45 -45
  32. package/src/tests/components/checkbox-group.spec.js +53 -53
  33. package/src/tests/components/checkbox-one.spec.js +32 -32
  34. package/src/tests/components/datepicker.spec.js +22 -22
  35. package/src/tests/components/declarations-wrappers/input-declarations-wrapper.spec.js +67 -67
  36. package/src/tests/components/declarations-wrappers/list-declarations-wrapper.spec.js +52 -52
  37. package/src/tests/components/declarations-wrappers/simple-declarations-wrapper.spec.js +21 -21
  38. package/src/tests/components/declarations.spec.js +46 -46
  39. package/src/tests/components/input.spec.js +18 -18
  40. package/src/tests/components/loops/loop-static.json +66 -66
  41. package/src/tests/components/loops/loop.json +258 -258
  42. package/src/tests/components/loops/loop.spec.js +30 -30
  43. package/src/tests/components/loops/roster-for-loop.spec.js +18 -18
  44. package/src/tests/components/progress-bar.spec.js +15 -15
  45. package/src/tests/components/radio.spec.js +27 -27
  46. package/src/tests/components/sequence.spec.js +9 -9
  47. package/src/tests/components/subsequence.spec.js +9 -9
  48. package/src/tests/components/table.spec.js +11 -11
  49. package/src/tests/components/textarea.spec.js +18 -18
  50. package/src/tests/components/tooltip.spec.js +25 -25
  51. package/src/tests/setup/setupTests.js +4 -4
  52. package/src/tests/utils/lib/alphabet.spec.js +36 -36
  53. package/src/tests/utils/lib/array.spec.js +22 -22
  54. package/src/tests/utils/lib/checkbox/group.spec.js +72 -72
  55. package/src/tests/utils/lib/decorator/title-decorator.spec.js +12 -12
  56. package/src/tests/utils/lib/input-number.spec.js +18 -18
  57. package/src/tests/utils/lib/items-positioning.spec.js +17 -17
  58. package/src/tests/utils/lib/label-position.spec.js +22 -22
  59. package/src/tests/utils/lib/loops/bindings.spec.js +75 -75
  60. package/src/tests/utils/lib/loops/shared.spec.js +82 -82
  61. package/src/tests/utils/lib/missing/missing.spec.js +74 -74
  62. package/src/tests/utils/lib/missing/mock.js +137 -137
  63. package/src/tests/utils/lib/pagination/shared.spec.js +42 -42
  64. package/src/tests/utils/lib/responses.spec.js +64 -64
  65. package/src/tests/utils/lib/style.spec.js +26 -26
  66. package/src/tests/utils/lib/tooltip/build-response.spec.js +95 -95
  67. package/src/tests/utils/lib/tooltip/content.spec.js +109 -109
  68. package/src/tests/utils/to-expose/handler/handler.spec.js +94 -94
  69. package/src/tests/utils/to-expose/handler/questionnaire.json +158 -158
  70. package/src/tests/utils/to-expose/handler/results/index.js +6 -6
  71. package/src/tests/utils/to-expose/handler/results/res-double.json +158 -158
  72. package/src/tests/utils/to-expose/handler/results/res-input-collected.json +158 -158
  73. package/src/tests/utils/to-expose/handler/results/res-loop.json +158 -158
  74. package/src/tests/utils/to-expose/handler/results/res-matrix.json +158 -158
  75. package/src/tests/utils/to-expose/handler/results/res-responses.json +158 -158
  76. package/src/tests/utils/to-expose/hooks/use-lunatic.spec.js +46 -46
  77. package/src/tests/utils/to-expose/init-questionnaire/data.json +12 -12
  78. package/src/tests/utils/to-expose/init-questionnaire/init-questionnaire.spec.js +19 -19
  79. package/src/tests/utils/to-expose/interpret/interpret.spec.js +48 -48
  80. package/src/tests/utils/to-expose/state/questionnaire.json +61 -61
  81. package/src/tests/utils/to-expose/state/results.js +78 -78
  82. package/src/utils/lib/tooltip/build-response.js +41 -41
  83. package/src/utils/store-tools/create/index.js +1 -1
  84. package/src/utils/store-tools/create/update-store-info.js +26 -26
  85. package/src/utils/store-tools/index.js +5 -5
@@ -1,137 +1,137 @@
1
- export const qRespTrue = {
2
- response: { name: 'response', values: { COLLECTED: 'toto' } },
3
- missingResponse: {
4
- name: 'missingResponse',
5
- values: { COLLECTED: 'toto' },
6
- },
7
- };
8
-
9
- export const qRespFalse = {
10
- response: { name: 'response', values: { COLLECTED: null } },
11
- missingResponse: {
12
- name: 'missingResponse',
13
- values: { COLLECTED: 'toto' },
14
- },
15
- };
16
-
17
- export const qRespsTrue = {
18
- responses: [
19
- {
20
- response: { name: 'response1', values: { COLLECTED: 'ok' } },
21
- },
22
- {
23
- response: { name: 'response2', values: { COLLECTED: 'ok' } },
24
- },
25
- ],
26
- missingResponse: {
27
- name: 'missingResponse',
28
- values: { COLLECTED: 'toto' },
29
- },
30
- };
31
-
32
- export const qRespsFalse = {
33
- responses: [
34
- {
35
- response: { name: 'response1', values: { COLLECTED: null } },
36
- },
37
- {
38
- response: { name: 'response2', values: { COLLECTED: null } },
39
- },
40
- ],
41
- missingResponse: {
42
- name: 'missingResponse',
43
- values: { COLLECTED: 'toto' },
44
- },
45
- };
46
-
47
- export const qCellsTrue = {
48
- cells: [
49
- [
50
- { label: 'line1' },
51
- {
52
- response: { name: 'response1', values: { COLLECTED: null } },
53
- },
54
- ],
55
- [
56
- { label: 'line2' },
57
- {
58
- response: { name: 'response2', values: { COLLECTED: 'ok' } },
59
- },
60
- ],
61
- ],
62
- };
63
-
64
- export const qCellsFalse = {
65
- cells: [
66
- [
67
- { label: 'line1' },
68
- {
69
- response: { name: 'response1', values: { COLLECTED: null } },
70
- },
71
- ],
72
- [
73
- { label: 'line2' },
74
- {
75
- response: { name: 'response2', values: { COLLECTED: null } },
76
- },
77
- ],
78
- ],
79
- };
80
-
81
- export const qComponentsTrue = {
82
- components: [
83
- {
84
- response: { name: 'response1', values: { COLLECTED: null } },
85
- },
86
- {
87
- responses: [
88
- {
89
- response: {
90
- name: 'response2',
91
- values: {
92
- COLLECTED: [
93
- ['ok', 'ok'],
94
- ['ok', 'ok'],
95
- ],
96
- },
97
- },
98
- },
99
- ],
100
- },
101
- {
102
- cells: [
103
- [
104
- { label: 'line1' },
105
- {
106
- response: { name: 'response3', values: { COLLECTED: 'ok' } },
107
- },
108
- ],
109
- ],
110
- },
111
- ],
112
- };
113
-
114
- export const qComponentsFalse = {
115
- components: [
116
- {
117
- response: { name: 'response1', values: { COLLECTED: null } },
118
- },
119
- {
120
- responses: [
121
- {
122
- response: { name: 'response2', values: { COLLECTED: null } },
123
- },
124
- ],
125
- },
126
- {
127
- cells: [
128
- [
129
- { label: 'line1' },
130
- {
131
- response: { name: 'response3', values: { COLLECTED: null } },
132
- },
133
- ],
134
- ],
135
- },
136
- ],
137
- };
1
+ export const qRespTrue = {
2
+ response: { name: 'response', values: { COLLECTED: 'toto' } },
3
+ missingResponse: {
4
+ name: 'missingResponse',
5
+ values: { COLLECTED: 'toto' },
6
+ },
7
+ };
8
+
9
+ export const qRespFalse = {
10
+ response: { name: 'response', values: { COLLECTED: null } },
11
+ missingResponse: {
12
+ name: 'missingResponse',
13
+ values: { COLLECTED: 'toto' },
14
+ },
15
+ };
16
+
17
+ export const qRespsTrue = {
18
+ responses: [
19
+ {
20
+ response: { name: 'response1', values: { COLLECTED: 'ok' } },
21
+ },
22
+ {
23
+ response: { name: 'response2', values: { COLLECTED: 'ok' } },
24
+ },
25
+ ],
26
+ missingResponse: {
27
+ name: 'missingResponse',
28
+ values: { COLLECTED: 'toto' },
29
+ },
30
+ };
31
+
32
+ export const qRespsFalse = {
33
+ responses: [
34
+ {
35
+ response: { name: 'response1', values: { COLLECTED: null } },
36
+ },
37
+ {
38
+ response: { name: 'response2', values: { COLLECTED: null } },
39
+ },
40
+ ],
41
+ missingResponse: {
42
+ name: 'missingResponse',
43
+ values: { COLLECTED: 'toto' },
44
+ },
45
+ };
46
+
47
+ export const qCellsTrue = {
48
+ cells: [
49
+ [
50
+ { label: 'line1' },
51
+ {
52
+ response: { name: 'response1', values: { COLLECTED: null } },
53
+ },
54
+ ],
55
+ [
56
+ { label: 'line2' },
57
+ {
58
+ response: { name: 'response2', values: { COLLECTED: 'ok' } },
59
+ },
60
+ ],
61
+ ],
62
+ };
63
+
64
+ export const qCellsFalse = {
65
+ cells: [
66
+ [
67
+ { label: 'line1' },
68
+ {
69
+ response: { name: 'response1', values: { COLLECTED: null } },
70
+ },
71
+ ],
72
+ [
73
+ { label: 'line2' },
74
+ {
75
+ response: { name: 'response2', values: { COLLECTED: null } },
76
+ },
77
+ ],
78
+ ],
79
+ };
80
+
81
+ export const qComponentsTrue = {
82
+ components: [
83
+ {
84
+ response: { name: 'response1', values: { COLLECTED: null } },
85
+ },
86
+ {
87
+ responses: [
88
+ {
89
+ response: {
90
+ name: 'response2',
91
+ values: {
92
+ COLLECTED: [
93
+ ['ok', 'ok'],
94
+ ['ok', 'ok'],
95
+ ],
96
+ },
97
+ },
98
+ },
99
+ ],
100
+ },
101
+ {
102
+ cells: [
103
+ [
104
+ { label: 'line1' },
105
+ {
106
+ response: { name: 'response3', values: { COLLECTED: 'ok' } },
107
+ },
108
+ ],
109
+ ],
110
+ },
111
+ ],
112
+ };
113
+
114
+ export const qComponentsFalse = {
115
+ components: [
116
+ {
117
+ response: { name: 'response1', values: { COLLECTED: null } },
118
+ },
119
+ {
120
+ responses: [
121
+ {
122
+ response: { name: 'response2', values: { COLLECTED: null } },
123
+ },
124
+ ],
125
+ },
126
+ {
127
+ cells: [
128
+ [
129
+ { label: 'line1' },
130
+ {
131
+ response: { name: 'response3', values: { COLLECTED: null } },
132
+ },
133
+ ],
134
+ ],
135
+ },
136
+ ],
137
+ };
@@ -1,42 +1,42 @@
1
- import { splitPage } from 'utils/lib';
2
-
3
- describe('string utils', () => {
4
- describe('splitPage', () => {
5
- it('should return splitted pages without depth', () => {
6
- const {
7
- currentRootPage,
8
- currentComponentIndex,
9
- currentIteration,
10
- currentPageWithoutAnyIteration,
11
- } = splitPage('1.2#3.10#1');
12
- expect(currentRootPage).toEqual('1.2#3');
13
- expect(currentComponentIndex).toEqual(10);
14
- expect(currentIteration).toEqual(1);
15
- expect(currentPageWithoutAnyIteration).toEqual('1.2.10');
16
- });
17
- it('should return splitted pages with depth 1', () => {
18
- const {
19
- currentRootPage,
20
- currentComponentIndex,
21
- currentIteration,
22
- currentPageWithoutAnyIteration,
23
- } = splitPage('1.2#3.10#1', 1);
24
- expect(currentRootPage).toEqual('1');
25
- expect(currentComponentIndex).toEqual(2);
26
- expect(currentIteration).toEqual(3);
27
- expect(currentPageWithoutAnyIteration).toEqual('1.2');
28
- });
29
- it('should return splitted pages with depth 2', () => {
30
- const {
31
- currentRootPage,
32
- currentComponentIndex,
33
- currentIteration,
34
- currentPageWithoutAnyIteration,
35
- } = splitPage('1.2#3.10#1', 2);
36
- expect(currentRootPage).toEqual('1.2#3');
37
- expect(currentComponentIndex).toEqual(10);
38
- expect(currentIteration).toEqual(1);
39
- expect(currentPageWithoutAnyIteration).toEqual('1.2.10');
40
- });
41
- });
42
- });
1
+ import { splitPage } from 'utils/lib';
2
+
3
+ describe('string utils', () => {
4
+ describe('splitPage', () => {
5
+ it('should return splitted pages without depth', () => {
6
+ const {
7
+ currentRootPage,
8
+ currentComponentIndex,
9
+ currentIteration,
10
+ currentPageWithoutAnyIteration,
11
+ } = splitPage('1.2#3.10#1');
12
+ expect(currentRootPage).toEqual('1.2#3');
13
+ expect(currentComponentIndex).toEqual(10);
14
+ expect(currentIteration).toEqual(1);
15
+ expect(currentPageWithoutAnyIteration).toEqual('1.2.10');
16
+ });
17
+ it('should return splitted pages with depth 1', () => {
18
+ const {
19
+ currentRootPage,
20
+ currentComponentIndex,
21
+ currentIteration,
22
+ currentPageWithoutAnyIteration,
23
+ } = splitPage('1.2#3.10#1', 1);
24
+ expect(currentRootPage).toEqual('1');
25
+ expect(currentComponentIndex).toEqual(2);
26
+ expect(currentIteration).toEqual(3);
27
+ expect(currentPageWithoutAnyIteration).toEqual('1.2');
28
+ });
29
+ it('should return splitted pages with depth 2', () => {
30
+ const {
31
+ currentRootPage,
32
+ currentComponentIndex,
33
+ currentIteration,
34
+ currentPageWithoutAnyIteration,
35
+ } = splitPage('1.2#3.10#1', 2);
36
+ expect(currentRootPage).toEqual('1.2#3');
37
+ expect(currentComponentIndex).toEqual(10);
38
+ expect(currentIteration).toEqual(1);
39
+ expect(currentPageWithoutAnyIteration).toEqual('1.2.10');
40
+ });
41
+ });
42
+ });
@@ -1,64 +1,64 @@
1
- import * as R from 'utils/lib/responses';
2
-
3
- describe('responses utils', () => {
4
- describe('getResponseName', () => {
5
- it('should return default value', () => {
6
- expect(R.getResponseName({})).toEqual('');
7
- });
8
- });
9
- describe('getResponseByPreference', () => {
10
- it('should return default value', () => {
11
- expect(R.getResponseByPreference([])({})).toEqual(null);
12
- expect(
13
- R.getResponseByPreference([])({
14
- name: 'name',
15
- values: { COLLECTED: 'Collected' },
16
- })
17
- ).toEqual(null);
18
- });
19
- it('should return Collected', () => {
20
- expect(
21
- R.getResponseByPreference(['COLLECTED'])({
22
- name: 'name',
23
- values: { COLLECTED: 'Collected' },
24
- })
25
- ).toEqual('Collected');
26
- });
27
- it('should return Collected', () => {
28
- expect(
29
- R.getResponseByPreference(['COLLECTED'])({
30
- name: 'name',
31
- values: { COLLECTED: 'Collected', FORCED: 'Forced' },
32
- })
33
- ).toEqual('Collected');
34
- });
35
- it('should return Collected', () => {
36
- expect(
37
- R.getResponseByPreference(['COLLECTED', 'FORCED'])({
38
- name: 'name',
39
- values: {
40
- COLLECTED: 'Collected',
41
- FORCED: null,
42
- },
43
- })
44
- ).toEqual('Collected');
45
- });
46
- it('should return Forced', () => {
47
- expect(
48
- R.getResponseByPreference(['COLLECTED', 'FORCED'])({
49
- name: 'name',
50
- values: { COLLECTED: 'Collected', FORCED: 'Forced' },
51
- })
52
- ).toEqual('Forced');
53
- });
54
-
55
- it('should return ""', () => {
56
- expect(
57
- R.getResponseByPreference(['COLLECTED', 'FORCED', 'EDITED'])({
58
- name: 'name',
59
- values: { COLLECTED: 'Collected', FORCED: '', EDITED: null },
60
- })
61
- ).toEqual('');
62
- });
63
- });
64
- });
1
+ import * as R from 'utils/lib/responses';
2
+
3
+ describe('responses utils', () => {
4
+ describe('getResponseName', () => {
5
+ it('should return default value', () => {
6
+ expect(R.getResponseName({})).toEqual('');
7
+ });
8
+ });
9
+ describe('getResponseByPreference', () => {
10
+ it('should return default value', () => {
11
+ expect(R.getResponseByPreference([])({})).toEqual(null);
12
+ expect(
13
+ R.getResponseByPreference([])({
14
+ name: 'name',
15
+ values: { COLLECTED: 'Collected' },
16
+ })
17
+ ).toEqual(null);
18
+ });
19
+ it('should return Collected', () => {
20
+ expect(
21
+ R.getResponseByPreference(['COLLECTED'])({
22
+ name: 'name',
23
+ values: { COLLECTED: 'Collected' },
24
+ })
25
+ ).toEqual('Collected');
26
+ });
27
+ it('should return Collected', () => {
28
+ expect(
29
+ R.getResponseByPreference(['COLLECTED'])({
30
+ name: 'name',
31
+ values: { COLLECTED: 'Collected', FORCED: 'Forced' },
32
+ })
33
+ ).toEqual('Collected');
34
+ });
35
+ it('should return Collected', () => {
36
+ expect(
37
+ R.getResponseByPreference(['COLLECTED', 'FORCED'])({
38
+ name: 'name',
39
+ values: {
40
+ COLLECTED: 'Collected',
41
+ FORCED: null,
42
+ },
43
+ })
44
+ ).toEqual('Collected');
45
+ });
46
+ it('should return Forced', () => {
47
+ expect(
48
+ R.getResponseByPreference(['COLLECTED', 'FORCED'])({
49
+ name: 'name',
50
+ values: { COLLECTED: 'Collected', FORCED: 'Forced' },
51
+ })
52
+ ).toEqual('Forced');
53
+ });
54
+
55
+ it('should return ""', () => {
56
+ expect(
57
+ R.getResponseByPreference(['COLLECTED', 'FORCED', 'EDITED'])({
58
+ name: 'name',
59
+ values: { COLLECTED: 'Collected', FORCED: '', EDITED: null },
60
+ })
61
+ ).toEqual('');
62
+ });
63
+ });
64
+ });
@@ -1,26 +1,26 @@
1
- import { buildStyleObject } from 'utils/lib';
2
-
3
- describe('style', () => {
4
- describe('buildStyleObject', () => {
5
- it('should return an empty object', () => {
6
- expect(buildStyleObject()).toEqual({});
7
- expect(buildStyleObject({})).toEqual({});
8
- });
9
- it('should return same object', () => {
10
- expect(buildStyleObject({ border: 'border' })).toEqual({
11
- border: 'border',
12
- });
13
- });
14
- it('should return object with camelCase keys', () => {
15
- expect(
16
- buildStyleObject({
17
- 'border-top': '10',
18
- ':hover': { 'background-color': 'pink' },
19
- })
20
- ).toEqual({
21
- borderTop: '10',
22
- ':hover': { backgroundColor: 'pink' },
23
- });
24
- });
25
- });
26
- });
1
+ import { buildStyleObject } from 'utils/lib';
2
+
3
+ describe('style', () => {
4
+ describe('buildStyleObject', () => {
5
+ it('should return an empty object', () => {
6
+ expect(buildStyleObject()).toEqual({});
7
+ expect(buildStyleObject({})).toEqual({});
8
+ });
9
+ it('should return same object', () => {
10
+ expect(buildStyleObject({ border: 'border' })).toEqual({
11
+ border: 'border',
12
+ });
13
+ });
14
+ it('should return object with camelCase keys', () => {
15
+ expect(
16
+ buildStyleObject({
17
+ 'border-top': '10',
18
+ ':hover': { 'background-color': 'pink' },
19
+ })
20
+ ).toEqual({
21
+ borderTop: '10',
22
+ ':hover': { backgroundColor: 'pink' },
23
+ });
24
+ });
25
+ });
26
+ });