@inseefr/lunatic 3.4.8-rc.0 → 3.4.9

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 (205) hide show
  1. package/components/CheckboxGroup/CheckboxGroup.js +3 -1
  2. package/components/CheckboxGroup/CheckboxGroup.js.map +1 -1
  3. package/components/CheckboxGroup/CustomCheckboxGroup.d.ts +1 -1
  4. package/components/CheckboxGroup/CustomCheckboxGroup.js +2 -5
  5. package/components/CheckboxGroup/CustomCheckboxGroup.js.map +1 -1
  6. package/components/CheckboxOne/CheckboxOne.js +3 -1
  7. package/components/CheckboxOne/CheckboxOne.js.map +1 -1
  8. package/components/Datepicker/Datepicker.js +7 -1
  9. package/components/Datepicker/Datepicker.js.map +1 -1
  10. package/components/Input/Input.js +3 -1
  11. package/components/Input/Input.js.map +1 -1
  12. package/components/InputNumber/InputNumber.spec.js +12 -0
  13. package/components/InputNumber/InputNumber.spec.js.map +1 -1
  14. package/components/InputNumber/InputNumberThousand.js +3 -1
  15. package/components/InputNumber/InputNumberThousand.js.map +1 -1
  16. package/components/Radio/Radio.d.ts +1 -0
  17. package/components/Radio/Radio.js +3 -1
  18. package/components/Radio/Radio.js.map +1 -1
  19. package/components/library.d.ts +1 -0
  20. package/components/shared/Checkbox/CheckboxOption.d.ts +4 -0
  21. package/components/shared/Checkbox/CheckboxOption.js +4 -2
  22. package/components/shared/Checkbox/CheckboxOption.js.map +1 -1
  23. package/components/shared/Checkbox/CheckboxOption.spec.js +14 -0
  24. package/components/shared/Checkbox/CheckboxOption.spec.js.map +1 -1
  25. package/components/shared/Radio/RadioGroup.d.ts +1 -1
  26. package/components/shared/Radio/RadioGroup.js +2 -2
  27. package/components/shared/Radio/RadioGroup.js.map +1 -1
  28. package/components/shared/Radio/RadioOption.d.ts +1 -0
  29. package/components/shared/Radio/RadioOption.js +2 -2
  30. package/components/shared/Radio/RadioOption.js.map +1 -1
  31. package/components/shared/Radio/RadioOption.spec.js +12 -0
  32. package/components/shared/Radio/RadioOption.spec.js.map +1 -1
  33. package/components/type.d.ts +3 -0
  34. package/esm/components/CheckboxGroup/CheckboxGroup.js +3 -1
  35. package/esm/components/CheckboxGroup/CheckboxGroup.js.map +1 -1
  36. package/esm/components/CheckboxGroup/CustomCheckboxGroup.d.ts +1 -1
  37. package/esm/components/CheckboxGroup/CustomCheckboxGroup.js +2 -6
  38. package/esm/components/CheckboxGroup/CustomCheckboxGroup.js.map +1 -1
  39. package/esm/components/CheckboxOne/CheckboxOne.js +3 -1
  40. package/esm/components/CheckboxOne/CheckboxOne.js.map +1 -1
  41. package/esm/components/Datepicker/Datepicker.js +7 -1
  42. package/esm/components/Datepicker/Datepicker.js.map +1 -1
  43. package/esm/components/Input/Input.js +3 -1
  44. package/esm/components/Input/Input.js.map +1 -1
  45. package/esm/components/InputNumber/InputNumber.spec.js +12 -0
  46. package/esm/components/InputNumber/InputNumber.spec.js.map +1 -1
  47. package/esm/components/InputNumber/InputNumberThousand.js +3 -1
  48. package/esm/components/InputNumber/InputNumberThousand.js.map +1 -1
  49. package/esm/components/Radio/Radio.d.ts +1 -0
  50. package/esm/components/Radio/Radio.js +3 -1
  51. package/esm/components/Radio/Radio.js.map +1 -1
  52. package/esm/components/library.d.ts +1 -0
  53. package/esm/components/shared/Checkbox/CheckboxOption.d.ts +4 -0
  54. package/esm/components/shared/Checkbox/CheckboxOption.js +4 -2
  55. package/esm/components/shared/Checkbox/CheckboxOption.js.map +1 -1
  56. package/esm/components/shared/Checkbox/CheckboxOption.spec.js +14 -0
  57. package/esm/components/shared/Checkbox/CheckboxOption.spec.js.map +1 -1
  58. package/esm/components/shared/Radio/RadioGroup.d.ts +1 -1
  59. package/esm/components/shared/Radio/RadioGroup.js +2 -2
  60. package/esm/components/shared/Radio/RadioGroup.js.map +1 -1
  61. package/esm/components/shared/Radio/RadioOption.d.ts +1 -0
  62. package/esm/components/shared/Radio/RadioOption.js +2 -2
  63. package/esm/components/shared/Radio/RadioOption.js.map +1 -1
  64. package/esm/components/shared/Radio/RadioOption.spec.js +12 -0
  65. package/esm/components/shared/Radio/RadioOption.spec.js.map +1 -1
  66. package/esm/components/type.d.ts +3 -0
  67. package/esm/index.d.ts +0 -1
  68. package/esm/index.js +0 -1
  69. package/esm/index.js.map +1 -1
  70. package/esm/main.css +5 -2
  71. package/esm/main.css.map +1 -1
  72. package/esm/type.source.d.ts +25 -40
  73. package/esm/type.source.js +1 -0
  74. package/esm/type.source.js.map +1 -1
  75. package/esm/use-lunatic/commons/fill-components/fill-components.d.ts +1 -0
  76. package/esm/use-lunatic/commons/fill-components/fill-components.js +1 -1
  77. package/esm/use-lunatic/commons/fill-components/fill-components.js.map +1 -1
  78. package/esm/use-lunatic/commons/page.js +4 -1
  79. package/esm/use-lunatic/commons/page.js.map +1 -1
  80. package/esm/use-lunatic/lunatic-context.d.ts +7 -1
  81. package/esm/use-lunatic/lunatic-context.js +7 -1
  82. package/esm/use-lunatic/lunatic-context.js.map +1 -1
  83. package/esm/use-lunatic/props/getComponentTypeProps.d.ts +3 -0
  84. package/esm/use-lunatic/props/propOptions.d.ts +1 -1
  85. package/esm/use-lunatic/props/propOptions.js.map +1 -1
  86. package/esm/use-lunatic/reducer/reducerInitializer.d.ts +2 -1
  87. package/esm/use-lunatic/reducer/reducerInitializer.js +3 -1
  88. package/esm/use-lunatic/reducer/reducerInitializer.js.map +1 -1
  89. package/esm/use-lunatic/type.d.ts +7 -0
  90. package/esm/use-lunatic/use-lunatic.js +6 -1
  91. package/esm/use-lunatic/use-lunatic.js.map +1 -1
  92. package/esm/utils/search/SearchMiniSearch.spec.d.ts +1 -0
  93. package/esm/utils/search/SearchMiniSearch.spec.js +51 -0
  94. package/esm/utils/search/SearchMiniSearch.spec.js.map +1 -0
  95. package/esm/utils/search/melauto.js +1 -1
  96. package/esm/utils/search/melauto.spec.d.ts +1 -0
  97. package/esm/utils/search/melauto.spec.js +67 -0
  98. package/esm/utils/search/melauto.spec.js.map +1 -0
  99. package/esm/utils/search/tokenizer.d.ts +7 -2
  100. package/esm/utils/search/tokenizer.js +23 -8
  101. package/esm/utils/search/tokenizer.js.map +1 -1
  102. package/esm/utils/search/tokenizer.spec.d.ts +1 -0
  103. package/esm/utils/search/tokenizer.spec.js +160 -0
  104. package/esm/utils/search/tokenizer.spec.js.map +1 -0
  105. package/index.d.ts +0 -1
  106. package/index.js +1 -4
  107. package/index.js.map +1 -1
  108. package/main.css +5 -2
  109. package/main.css.map +1 -1
  110. package/package.json +28 -1
  111. package/src/components/CheckboxGroup/CheckboxGroup.tsx +3 -0
  112. package/src/components/CheckboxGroup/CustomCheckboxGroup.tsx +3 -14
  113. package/src/components/CheckboxOne/CheckboxOne.tsx +3 -0
  114. package/src/components/Datepicker/Datepicker.tsx +8 -1
  115. package/src/components/Input/Input.tsx +4 -0
  116. package/src/components/Input/__snapshots__/Input.spec.tsx.snap +2 -0
  117. package/src/components/InputNumber/InputNumber.spec.tsx +20 -0
  118. package/src/components/InputNumber/InputNumberThousand.tsx +4 -0
  119. package/src/components/InputNumber/__snapshots__/InputNumber.spec.tsx.snap +2 -0
  120. package/src/components/Radio/Radio.tsx +3 -0
  121. package/src/components/RosterForLoop/__snapshots__/RosterForLoop.spec.tsx.snap +2 -0
  122. package/src/components/shared/Checkbox/CheckboxOption.spec.tsx +21 -0
  123. package/src/components/shared/Checkbox/CheckboxOption.tsx +19 -0
  124. package/src/components/shared/Radio/RadioGroup.tsx +3 -0
  125. package/src/components/shared/Radio/RadioOption.spec.tsx +36 -0
  126. package/src/components/shared/Radio/RadioOption.tsx +5 -1
  127. package/src/components/type.ts +3 -0
  128. package/src/css/components/CheckboxOne.scss +1 -1
  129. package/src/css/components/CheckboxOption.scss +14 -18
  130. package/src/css/components/Combobox.scss +3 -2
  131. package/src/css/components/Datepicker.scss +8 -8
  132. package/src/css/components/Declarations.scss +1 -1
  133. package/src/css/components/Dragger.scss +6 -6
  134. package/src/css/components/Duration.scss +4 -4
  135. package/src/css/components/IconButton.scss +4 -2
  136. package/src/css/components/Input.scss +3 -0
  137. package/src/css/components/Missing.scss +1 -1
  138. package/src/css/components/Roundabout.scss +3 -3
  139. package/src/css/components/Suggester.scss +2 -2
  140. package/src/css/components/Table.scss +9 -7
  141. package/src/css/main.scss +167 -167
  142. package/src/index.ts +0 -2
  143. package/src/stories/behaviour/filter/dataLoop.json +22 -0
  144. package/src/stories/behaviour/filter/filter.stories.jsx +36 -0
  145. package/src/stories/behaviour/filter/source.json +238 -0
  146. package/src/stories/behaviour/filter/sourceLoop.json +372 -0
  147. package/src/stories/behaviour/missing/missing.stories.jsx +9 -0
  148. package/src/stories/behaviour/paste/test.stories.jsx +5 -0
  149. package/src/stories/checkbox-group/checkbox-group.stories.jsx +25 -6
  150. package/src/stories/checkbox-one/checkboxOne.stories.jsx +24 -2
  151. package/src/stories/overview/overview.stories.jsx +8 -1
  152. package/src/stories/radio/radio.stories.jsx +46 -6
  153. package/src/stories/utils/default-arg-types.js +12 -1
  154. package/src/stories/utils/default-args.js +3 -0
  155. package/src/stories/utils/orchestrator.jsx +11 -1
  156. package/src/stories/utils/orchestrator.scss +9 -7
  157. package/src/stories/utils/overview.scss +0 -1
  158. package/src/type.source.ts +93 -108
  159. package/src/use-lunatic/commons/fill-components/fill-components.ts +4 -1
  160. package/src/use-lunatic/commons/page.ts +4 -1
  161. package/src/use-lunatic/lunatic-context.tsx +9 -0
  162. package/src/use-lunatic/props/propOptions.ts +2 -1
  163. package/src/use-lunatic/reducer/reducerInitializer.tsx +4 -0
  164. package/src/use-lunatic/type.ts +5 -0
  165. package/src/use-lunatic/use-lunatic.test.ts +52 -0
  166. package/src/use-lunatic/use-lunatic.ts +7 -0
  167. package/src/utils/search/SearchMiniSearch.spec.ts +58 -0
  168. package/src/utils/search/melauto.spec.ts +75 -0
  169. package/src/utils/search/melauto.ts +1 -1
  170. package/src/utils/search/tokenizer.spec.ts +205 -0
  171. package/src/utils/search/tokenizer.ts +27 -8
  172. package/tsconfig.build.tsbuildinfo +1 -1
  173. package/type.source.d.ts +25 -40
  174. package/type.source.js +1 -0
  175. package/type.source.js.map +1 -1
  176. package/use-lunatic/commons/fill-components/fill-components.d.ts +1 -0
  177. package/use-lunatic/commons/fill-components/fill-components.js +1 -1
  178. package/use-lunatic/commons/fill-components/fill-components.js.map +1 -1
  179. package/use-lunatic/commons/page.js +4 -1
  180. package/use-lunatic/commons/page.js.map +1 -1
  181. package/use-lunatic/lunatic-context.d.ts +7 -1
  182. package/use-lunatic/lunatic-context.js +9 -2
  183. package/use-lunatic/lunatic-context.js.map +1 -1
  184. package/use-lunatic/props/getComponentTypeProps.d.ts +3 -0
  185. package/use-lunatic/props/propOptions.d.ts +1 -1
  186. package/use-lunatic/props/propOptions.js.map +1 -1
  187. package/use-lunatic/reducer/reducerInitializer.d.ts +2 -1
  188. package/use-lunatic/reducer/reducerInitializer.js +3 -1
  189. package/use-lunatic/reducer/reducerInitializer.js.map +1 -1
  190. package/use-lunatic/type.d.ts +7 -0
  191. package/use-lunatic/use-lunatic.js +6 -1
  192. package/use-lunatic/use-lunatic.js.map +1 -1
  193. package/utils/search/SearchMiniSearch.spec.d.ts +1 -0
  194. package/utils/search/SearchMiniSearch.spec.js +51 -0
  195. package/utils/search/SearchMiniSearch.spec.js.map +1 -0
  196. package/utils/search/melauto.js +1 -1
  197. package/utils/search/melauto.spec.d.ts +1 -0
  198. package/utils/search/melauto.spec.js +69 -0
  199. package/utils/search/melauto.spec.js.map +1 -0
  200. package/utils/search/tokenizer.d.ts +7 -2
  201. package/utils/search/tokenizer.js +24 -8
  202. package/utils/search/tokenizer.js.map +1 -1
  203. package/utils/search/tokenizer.spec.d.ts +1 -0
  204. package/utils/search/tokenizer.spec.js +162 -0
  205. package/utils/search/tokenizer.spec.js.map +1 -0
@@ -18,7 +18,7 @@
18
18
  .story-with-sidebar aside label {
19
19
  display: block;
20
20
  font-weight: bold;
21
- margin-bottom: .3em;
21
+ margin-bottom: 0.3em;
22
22
  }
23
23
 
24
24
  .story-with-sidebar aside {
@@ -26,7 +26,9 @@
26
26
  grid-template-columns: 1fr;
27
27
  gap: 1rem;
28
28
  padding: 1rem;
29
- box-shadow: 0 4px 3px rgba(0, 0, 0, 0.07), 0px 2px 2px rgba(0, 0, 0, 0.06);
29
+ box-shadow:
30
+ 0 4px 3px rgba(0, 0, 0, 0.07),
31
+ 0px 2px 2px rgba(0, 0, 0, 0.06);
30
32
  background-color: #f1f5f9;
31
33
 
32
34
  .pagination {
@@ -36,8 +38,8 @@
36
38
 
37
39
  .story-pager h3 {
38
40
  font-size: 1rem;
39
- padding-bottom: .3rem;
40
- margin-bottom: .5rem;
41
+ padding-bottom: 0.3rem;
42
+ margin-bottom: 0.5rem;
41
43
  border-bottom: solid 1px rgba(0, 0, 0, 0.3);
42
44
  }
43
45
 
@@ -46,7 +48,7 @@
46
48
  padding: 0 0 0 20px;
47
49
  line-height: 1.4;
48
50
  font-size: 0.9rem;
49
- color: rgba(0, 0, 0, 0.75)
51
+ color: rgba(0, 0, 0, 0.75);
50
52
  }
51
53
 
52
54
  .story-pager ul strong {
@@ -57,8 +59,8 @@
57
59
  color: #721c24;
58
60
  background-color: #f8d7da;
59
61
  position: relative;
60
- padding: .75rem 1.25rem;
62
+ padding: 0.75rem 1.25rem;
61
63
  margin-bottom: 1rem;
62
64
  border: 1px solid #f5c6cb;
63
- border-radius: .25rem;
65
+ border-radius: 0.25rem;
64
66
  }
@@ -35,4 +35,3 @@
35
35
  list-style: none;
36
36
  }
37
37
  }
38
-
@@ -1,3 +1,4 @@
1
+ /* eslint-disable */
1
2
  /**
2
3
  * This file was automatically generated by json-schema-to-typescript.
3
4
  * DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
@@ -34,20 +35,18 @@ export type ComponentDefinition =
34
35
  | ComponentSummaryDefinition
35
36
  | ComponentText
36
37
  | ComponentAccordion;
37
- export type ComponentInputDefinition = ComponentInputDefinition1 & {
38
+ export type ComponentInputDefinition = ComponentDefinitionBaseWithResponse & {
38
39
  componentType: 'Input' | 'Textarea';
39
40
  maxLength?: number;
40
41
  };
41
- export type ComponentInputDefinition1 = ComponentDefinitionBaseWithResponse;
42
42
  export type ComponentDefinitionBaseWithResponse = ComponentDefinitionBase & {
43
43
  response: ResponseDefinition;
44
44
  };
45
- export type ComponentSequenceDefinition = ComponentSequenceDefinition1 & {
45
+ export type ComponentSequenceDefinition = ComponentDefinitionBase & {
46
46
  componentType: 'Sequence' | 'Subsequence';
47
47
  goToPage?: string;
48
48
  };
49
- export type ComponentSequenceDefinition1 = ComponentDefinitionBase;
50
- export type ComponentRoundaboutDefinition = ComponentRoundaboutDefinition1 & {
49
+ export type ComponentRoundaboutDefinition = ComponentDefinitionBase & {
51
50
  componentType: 'Roundabout';
52
51
  iterations: VTLScalarExpression;
53
52
  locked: boolean;
@@ -59,25 +58,22 @@ export type ComponentRoundaboutDefinition = ComponentRoundaboutDefinition1 & {
59
58
  };
60
59
  components: ComponentDefinitionWithPage[];
61
60
  };
62
- export type ComponentRoundaboutDefinition1 = ComponentDefinitionBase;
63
61
  export type ComponentLoopDefinition = {
64
62
  componentType: 'Loop';
65
63
  loopDependencies?: string[];
66
64
  } & ComponentLoopDefinition1;
67
65
  export type ComponentLoopDefinition1 = PaginatedLoop | BlockLoop;
68
- export type PaginatedLoop = PaginatedLoop1 & {
66
+ export type PaginatedLoop = ComponentDefinitionBase & {
69
67
  components: ComponentDefinitionWithPage[];
70
68
  iterations: VTLScalarExpression;
71
69
  maxPage: string;
72
70
  paginatedLoop: true;
73
71
  };
74
- export type PaginatedLoop1 = ComponentDefinitionBase;
75
- export type BlockLoop = BlockLoop1 & {
72
+ export type BlockLoop = ComponentDefinitionBase & {
76
73
  paginatedLoop: false;
77
74
  components: ComponentDefinition[];
78
- } & BlockLoop2;
79
- export type BlockLoop1 = ComponentDefinitionBase;
80
- export type BlockLoop2 =
75
+ } & BlockLoop1;
76
+ export type BlockLoop1 =
81
77
  | {
82
78
  lines: {
83
79
  min: VTLExpression;
@@ -87,17 +83,15 @@ export type BlockLoop2 =
87
83
  | {
88
84
  iterations: VTLExpression;
89
85
  };
90
- export type ComponentRosterForLoopDefinition =
91
- ComponentRosterForLoopDefinition1 & {
92
- componentType: 'RosterForLoop';
93
- components: ComponentDefinition[];
94
- lines: {
95
- min: VTLScalarExpression;
96
- max: VTLScalarExpression;
97
- };
98
- header?: TableHeader;
86
+ export type ComponentRosterForLoopDefinition = ComponentDefinitionBase & {
87
+ componentType: 'RosterForLoop';
88
+ components: ComponentDefinition[];
89
+ lines: {
90
+ min: VTLScalarExpression;
91
+ max: VTLScalarExpression;
99
92
  };
100
- export type ComponentRosterForLoopDefinition1 = ComponentDefinitionBase;
93
+ header?: TableHeader;
94
+ };
101
95
  export type Options = {
102
96
  value: string | boolean;
103
97
  label: VTLExpression;
@@ -111,7 +105,7 @@ export type TableHeader = {
111
105
  rowspan?: number;
112
106
  options?: Options;
113
107
  }[];
114
- export type ComponentTableDefinition = ComponentTableDefinition1 & {
108
+ export type ComponentTableDefinition = ComponentDefinitionBase & {
115
109
  componentType: 'Table';
116
110
  header?: TableHeader;
117
111
  body: (
@@ -121,57 +115,49 @@ export type ComponentTableDefinition = ComponentTableDefinition1 & {
121
115
  }
122
116
  )[][];
123
117
  };
124
- export type ComponentTableDefinition1 = ComponentDefinitionBase;
125
- export type ComponentNumberDefinition = ComponentNumberDefinition1 & {
118
+ export type ComponentNumberDefinition = ComponentDefinitionBaseWithResponse & {
126
119
  componentType: 'InputNumber';
127
120
  unit?: string | VTLExpression;
128
121
  min?: number;
129
122
  max?: number;
130
123
  decimals?: number;
131
124
  };
132
- export type ComponentNumberDefinition1 = ComponentDefinitionBaseWithResponse;
133
- export type ComponentDurationDefinition = ComponentDurationDefinition1 & {
134
- componentType: 'Duration';
135
- format: 'PnYnM' | 'PTnHnM';
136
- };
137
- export type ComponentDurationDefinition1 = ComponentDefinitionBaseWithResponse;
138
- export type ComponentDatePickerDefinition = ComponentDatePickerDefinition1 & {
139
- componentType: 'Datepicker';
140
- dateFormat: 'YYYY-MM-DD' | 'YYYY' | 'YYYY-MM';
141
- min?: string;
142
- max?: string;
143
- };
144
- export type ComponentDatePickerDefinition1 =
145
- ComponentDefinitionBaseWithResponse;
146
- export type ComponentCheckboxGroupDefinition =
147
- ComponentCheckboxGroupDefinition1 & {
148
- componentType: 'CheckboxGroup';
149
- orientation?: 'horizontal' | 'vertical';
150
- responses: {
151
- label: VTLExpression;
152
- description?: VTLExpression;
153
- response: ResponseDefinition;
154
- conditionFilter?: VTLExpression;
155
- id: string;
156
- detail?: {
157
- label?: VTLExpression;
158
- response: ResponseDefinition;
159
- };
160
- }[];
125
+ export type ComponentDurationDefinition =
126
+ ComponentDefinitionBaseWithResponse & {
127
+ componentType: 'Duration';
128
+ format: 'PnYnM' | 'PTnHnM';
161
129
  };
162
- export type ComponentCheckboxGroupDefinition1 = ComponentDefinitionBase;
130
+ export type ComponentDatePickerDefinition =
131
+ ComponentDefinitionBaseWithResponse & {
132
+ componentType: 'Datepicker';
133
+ dateFormat: 'YYYY-MM-DD' | 'YYYY' | 'YYYY-MM';
134
+ min?: string;
135
+ max?: string;
136
+ };
137
+ export type ComponentCheckboxGroupDefinition = ComponentDefinitionBase & {
138
+ componentType: 'CheckboxGroup';
139
+ orientation?: 'horizontal' | 'vertical';
140
+ responses: {
141
+ label: VTLExpression;
142
+ description?: VTLExpression;
143
+ response: ResponseDefinition;
144
+ conditionFilter?: VTLExpression;
145
+ id: string;
146
+ detail?: {
147
+ label?: VTLExpression;
148
+ response: ResponseDefinition;
149
+ };
150
+ }[];
151
+ };
163
152
  export type ComponentCheckboxBooleanDefinition =
164
- ComponentCheckboxBooleanDefinition1 & {
153
+ ComponentDefinitionBaseWithResponse & {
165
154
  componentType: 'CheckboxBoolean';
166
155
  };
167
- export type ComponentCheckboxBooleanDefinition1 =
168
- ComponentDefinitionBaseWithResponse;
169
- export type ComponentRadioDefinition = ComponentRadioDefinition1 & {
156
+ export type ComponentRadioDefinition = ComponentDefinitionBaseWithResponse & {
170
157
  componentType: 'Radio';
171
158
  orientation?: 'horizontal' | 'vertical';
172
159
  options: OptionsWithDetail;
173
160
  };
174
- export type ComponentRadioDefinition1 = ComponentDefinitionBaseWithResponse;
175
161
  export type OptionsWithDetail = {
176
162
  value: string | boolean;
177
163
  label: VTLExpression;
@@ -183,63 +169,59 @@ export type OptionsWithDetail = {
183
169
  };
184
170
  };
185
171
  }[];
186
- export type ComponentDropdownDefinition = ComponentDropdownDefinition1 & {
187
- componentType: 'Dropdown';
188
- options: Options;
189
- };
190
- export type ComponentDropdownDefinition1 = ComponentDefinitionBaseWithResponse;
191
- export type ComponentQuestionDefinition = ComponentQuestionDefinition1 & {
172
+ export type ComponentDropdownDefinition =
173
+ ComponentDefinitionBaseWithResponse & {
174
+ componentType: 'Dropdown';
175
+ options: Options;
176
+ };
177
+ export type ComponentQuestionDefinition = ComponentDefinitionBase & {
192
178
  componentType: 'Question';
193
179
  components: ComponentDefinition[];
194
180
  };
195
- export type ComponentQuestionDefinition1 = ComponentDefinitionBase;
196
- export type ComponentCheckboxOneDefinition = ComponentCheckboxOneDefinition1 & {
197
- componentType: 'CheckboxOne';
198
- options: OptionsWithDetail;
199
- };
200
- export type ComponentCheckboxOneDefinition1 =
201
- ComponentDefinitionBaseWithResponse;
202
- export type ComponentSuggesterDefinition = ComponentSuggesterDefinition1 & {
203
- componentType: 'Suggester';
204
- /**
205
- * Nom / Index du référentiel à utiliser
206
- */
207
- storeName: string;
208
- /**
209
- * Permet l'entrée d'une valeur arbitraire (Autre)
210
- */
211
- arbitrary?: {
212
- response: ResponseDefinition;
181
+ export type ComponentCheckboxOneDefinition =
182
+ ComponentDefinitionBaseWithResponse & {
183
+ componentType: 'CheckboxOne';
184
+ options: OptionsWithDetail;
213
185
  };
214
- /**
215
- * Liste des attributs de la nomenclature à sauvegarder dans une variable
216
- */
217
- optionResponses?: {
186
+ export type ComponentSuggesterDefinition =
187
+ ComponentDefinitionBaseWithResponse & {
188
+ componentType: 'Suggester';
218
189
  /**
219
- * Nom de la variable
190
+ * Nom / Index du référentiel à utiliser
220
191
  */
221
- name: string;
192
+ storeName: string;
222
193
  /**
223
- * Nom de la propriété dans la nomenclature
194
+ * Permet l'entrée d'une valeur arbitraire (Autre)
224
195
  */
225
- attribute: string;
226
- }[];
227
- };
228
- export type ComponentSuggesterDefinition1 = ComponentDefinitionBaseWithResponse;
229
- export type ComponentPairWiseLinksDefinition =
230
- ComponentPairWiseLinksDefinition1 & {
231
- componentType: 'PairwiseLinks';
232
- xAxisIterations: VTLScalarExpression;
233
- yAxisIterations: VTLScalarExpression;
234
- symLinks: {
235
- [k: string]: {
236
- [k: string]: string | null;
237
- };
196
+ arbitrary?: {
197
+ response: ResponseDefinition;
198
+ };
199
+ /**
200
+ * Liste des attributs de la nomenclature à sauvegarder dans une variable
201
+ */
202
+ optionResponses?: {
203
+ /**
204
+ * Nom de la variable
205
+ */
206
+ name: string;
207
+ /**
208
+ * Nom de la propriété dans la nomenclature
209
+ */
210
+ attribute: string;
211
+ }[];
212
+ };
213
+ export type ComponentPairWiseLinksDefinition = ComponentDefinitionBase & {
214
+ componentType: 'PairwiseLinks';
215
+ xAxisIterations: VTLScalarExpression;
216
+ yAxisIterations: VTLScalarExpression;
217
+ symLinks: {
218
+ [k: string]: {
219
+ [k: string]: string | null;
238
220
  };
239
- components: ComponentDefinition[];
240
221
  };
241
- export type ComponentPairWiseLinksDefinition1 = ComponentDefinitionBase;
242
- export type ComponentSummaryDefinition = ComponentSummaryDefinition1 & {
222
+ components: ComponentDefinition[];
223
+ };
224
+ export type ComponentSummaryDefinition = ComponentDefinitionBase & {
243
225
  componentType: 'Summary';
244
226
  sections: {
245
227
  id: string;
@@ -252,7 +234,6 @@ export type ComponentSummaryDefinition = ComponentSummaryDefinition1 & {
252
234
  }[];
253
235
  }[];
254
236
  };
255
- export type ComponentSummaryDefinition1 = ComponentDefinitionBase;
256
237
  export type Variable =
257
238
  | {
258
239
  variableType: 'EXTERNAL';
@@ -465,4 +446,8 @@ export type SuggesterDefinition = {
465
446
  | {
466
447
  type: 'soft';
467
448
  };
449
+ /**
450
+ * list of words to exclude from the searching
451
+ */
452
+ stopWords?: string[];
468
453
  };
@@ -14,6 +14,7 @@ import { getIterationsProp } from '../../props/propIterations';
14
14
  import { getOptionsProp } from '../../props/propOptions';
15
15
 
16
16
  type FillComponentArgs = {
17
+ disableFilters?: boolean;
17
18
  handleChanges: LunaticChangesHandler;
18
19
  executeExpression: LunaticReducerState['executeExpression'];
19
20
  goToPage: LunaticState['goToPage'];
@@ -71,5 +72,7 @@ export function fillComponents(
71
72
  ): LunaticComponentProps[] {
72
73
  return components
73
74
  .map((component) => fillComponent(component, state))
74
- .filter(({ conditionFilter }) => conditionFilter ?? true);
75
+ .filter(
76
+ ({ conditionFilter }) => state.disableFilters || (conditionFilter ?? true)
77
+ );
75
78
  }
@@ -24,10 +24,13 @@ export function pageStringToNumbers(page: string): number[] {
24
24
  * if no components can be displayed on this page (using filter)
25
25
  */
26
26
  export function isPageEmpty(state: LunaticReducerState): boolean {
27
- const { executeExpression, pager } = state;
27
+ const { executeExpression, pager, options } = state;
28
28
  const { iteration } = pager;
29
29
  const components = getComponentsFromState(state);
30
30
  const visibleComponents = components.filter((component) => {
31
+ if (options.disableFilters) {
32
+ return true;
33
+ }
31
34
  if ('conditionFilter' in component && component.conditionFilter) {
32
35
  return executeConditionFilter(
33
36
  component.conditionFilter,
@@ -15,6 +15,7 @@ const LunaticContext = createContext({
15
15
  missingShortcut: { dontKnow: '', refused: '' },
16
16
  dontKnowButton: D.DK,
17
17
  refusedButton: D.RF,
18
+ componentsOptions: { detailAlwaysDisplayed: false },
18
19
  });
19
20
  /** Provide `missing` `missingStrategy`, `shortcut` and `missingShortcut`, `dontKnowButton`, `refusedButton` to Missing component
20
21
  * to manage non-response buttons and shortcut */
@@ -37,6 +38,11 @@ export const useLunaticMissing = () => {
37
38
  };
38
39
  };
39
40
 
41
+ export const useLunaticComponentsOptions = () => {
42
+ const { componentsOptions } = useContext(LunaticContext);
43
+ return componentsOptions;
44
+ };
45
+
40
46
  /** Provide `management` to display data states [COLLECTED,EDITED,FORCED] */
41
47
  export const useLunaticManagement = () => {
42
48
  return useContext(LunaticContext).management;
@@ -50,6 +56,7 @@ export function createLunaticProvider({
50
56
  missingShortcut,
51
57
  dontKnowButton,
52
58
  refusedButton,
59
+ componentsOptions,
53
60
  }: {
54
61
  management: boolean;
55
62
  missing: boolean;
@@ -58,6 +65,7 @@ export function createLunaticProvider({
58
65
  missingShortcut: { dontKnow: string; refused: string };
59
66
  dontKnowButton: string;
60
67
  refusedButton: string;
68
+ componentsOptions: { detailAlwaysDisplayed: boolean };
61
69
  }): FunctionComponent<PropsWithChildren> {
62
70
  const value = {
63
71
  management,
@@ -67,6 +75,7 @@ export function createLunaticProvider({
67
75
  missingShortcut,
68
76
  dontKnowButton,
69
77
  refusedButton,
78
+ componentsOptions,
70
79
  };
71
80
  return function Provider({ children }: PropsWithChildren) {
72
81
  return (
@@ -8,12 +8,13 @@ import type { DeepTranslateExpression } from '../commons/fill-components/fill-co
8
8
  import { isNumber } from '../../utils/number';
9
9
  import type { LunaticVariablesStore } from '../commons/variables/lunatic-variables-store';
10
10
 
11
+ /* Used for radio option and checkbox one option */
11
12
  export type InterpretedOption = {
12
13
  label: ReactNode;
13
14
  value?: string;
14
15
  checked?: boolean;
15
- detailLabel?: ReactNode;
16
16
  description?: ReactNode;
17
+ detailLabel?: ReactNode;
17
18
  detailValue?: string | null;
18
19
  onDetailChange?: (value: string) => void;
19
20
  onCheck?: () => void;
@@ -35,6 +35,7 @@ const baseState = {
35
35
  overview: [],
36
36
  updateBindings: () => {},
37
37
  executeExpression: <T,>() => null as T,
38
+ options: { disableFilters: false },
38
39
  } satisfies LunaticReducerState;
39
40
 
40
41
  export function reducerInitializer({
@@ -44,6 +45,7 @@ export function reducerInitializer({
44
45
  initialPage = '1',
45
46
  lastReachedPage = undefined,
46
47
  withOverview = false,
48
+ disableFilters = false,
47
49
  getReferentiel,
48
50
  onVariableChange,
49
51
  logger,
@@ -54,6 +56,7 @@ export function reducerInitializer({
54
56
  initialPage?: LunaticOptions['initialPage'];
55
57
  lastReachedPage?: LunaticOptions['lastReachedPage'];
56
58
  withOverview?: LunaticOptions['withOverview'];
59
+ disableFilters?: LunaticOptions['disableFilters'];
57
60
  getReferentiel?: LunaticOptions['getReferentiel'];
58
61
  onVariableChange: RefObject<LunaticOptions['onVariableChange']>;
59
62
  logger: LunaticLogger;
@@ -145,6 +148,7 @@ export function reducerInitializer({
145
148
  overview: withOverview ? buildOverview(source) : [],
146
149
  updateBindings,
147
150
  executeExpression,
151
+ options: { disableFilters },
148
152
  });
149
153
  }
150
154
 
@@ -131,9 +131,13 @@ export type LunaticReducerState = {
131
131
  value: unknown,
132
132
  options: { iteration?: number[] }
133
133
  ) => unknown;
134
+ options: {
135
+ disableFilters?: boolean;
136
+ };
134
137
  };
135
138
 
136
139
  export type LunaticOptions = {
140
+ disableFilters?: boolean;
137
141
  features?: ('MD' | 'VTL')[];
138
142
  preferences?: ['COLLECTED'];
139
143
  savingType?: 'COLLECTED';
@@ -157,6 +161,7 @@ export type LunaticOptions = {
157
161
  // Enable change tracking to keep a track of what variable changed (allow using getChangedData())
158
162
  trackChanges?: boolean;
159
163
  logger?: LunaticLogger;
164
+ componentsOptions?: { detailAlwaysDisplayed?: boolean };
160
165
  };
161
166
 
162
167
  // Type representing the return type of "useLunatic()"
@@ -179,6 +179,58 @@ describe('use-lunatic()', () => {
179
179
  });
180
180
  });
181
181
 
182
+ describe('disable filters', () => {
183
+ const lunaticConfigurationWithoutDisableFilters = {
184
+ management: false,
185
+ activeControls: false,
186
+ initialPage: '1' as PageTag,
187
+ getStoreInfo: () => {},
188
+ missing: false,
189
+ shortcut: false,
190
+ activeGoNextForMissing: false,
191
+ showOverview: false,
192
+ filterDescription: true,
193
+ };
194
+
195
+ it('should filter out some components by default', function () {
196
+ const { result } = renderHook(() =>
197
+ useLunatic(
198
+ sourceLogement as any,
199
+ undefined,
200
+ lunaticConfigurationWithoutDisableFilters
201
+ )
202
+ );
203
+ act(() => result.current.goToPage({ page: '3' }));
204
+ const currentPage = result.current.pageTag;
205
+ expect(currentPage).not.toBe('3');
206
+ });
207
+ it('should filter out some components when false', function () {
208
+ const { result } = renderHook(() =>
209
+ useLunatic(sourceLogement as any, undefined, {
210
+ ...lunaticConfigurationWithoutDisableFilters,
211
+ disableFilters: false,
212
+ })
213
+ );
214
+ act(() => result.current.goToPage({ page: '3' }));
215
+ const currentPage = result.current.pageTag;
216
+ expect(currentPage).not.toBe('3');
217
+ });
218
+ it('should not filter any component when true', function () {
219
+ const { result } = renderHook(() =>
220
+ useLunatic(sourceLogement as any, undefined, {
221
+ ...lunaticConfigurationWithoutDisableFilters,
222
+ disableFilters: true,
223
+ })
224
+ );
225
+ act(() => result.current.goToPage({ page: '3' }));
226
+ const currentPage = result.current.pageTag;
227
+ expect(currentPage).toBe('3');
228
+
229
+ const components = result.current.getComponents();
230
+ expect(components.length).toBe(1);
231
+ });
232
+ });
233
+
182
234
  describe('cleaning', () => {
183
235
  it('should handle cleaning in a loop', () => {
184
236
  const { result } = renderHook(() =>
@@ -42,6 +42,7 @@ const DEFAULT_DONT_KNOW = D.DK;
42
42
  const DEFAULT_REFUSED = D.RF;
43
43
 
44
44
  const defaultOptions = {
45
+ disableFilters: false,
45
46
  features: DEFAULT_FEATURES,
46
47
  preferences: DEFAULT_PREFERENCES,
47
48
  savingType: COLLECTED,
@@ -62,6 +63,7 @@ const defaultOptions = {
62
63
  refusedButton: DEFAULT_REFUSED,
63
64
  trackChanges: false,
64
65
  logger: ConsoleLogger,
66
+ componentsOptions: { detailAlwaysDisplayed: false },
65
67
  } satisfies LunaticOptions;
66
68
 
67
69
  export function useLunatic(
@@ -71,6 +73,7 @@ export function useLunatic(
71
73
  ) {
72
74
  const options = mergeDefault(argOptions, defaultOptions);
73
75
  const {
76
+ disableFilters,
74
77
  management,
75
78
  missing,
76
79
  missingStrategy,
@@ -82,6 +85,7 @@ export function useLunatic(
82
85
  trackChanges,
83
86
  preferences,
84
87
  logger,
88
+ componentsOptions,
85
89
  } = options;
86
90
 
87
91
  // Help debug with warnings for options expected to be memoized
@@ -113,6 +117,7 @@ export function useLunatic(
113
117
  missingShortcut,
114
118
  dontKnowButton,
115
119
  refusedButton,
120
+ componentsOptions,
116
121
  }),
117
122
  [
118
123
  management,
@@ -122,6 +127,7 @@ export function useLunatic(
122
127
  missingShortcut,
123
128
  dontKnowButton,
124
129
  refusedButton,
130
+ componentsOptions,
125
131
  ]
126
132
  );
127
133
 
@@ -179,6 +185,7 @@ export function useLunatic(
179
185
  const { isFirstPage, isLastPage } = isFirstLastPage(state.pager);
180
186
 
181
187
  const components = fillComponents(getComponentsFromState(state), {
188
+ disableFilters,
182
189
  handleChanges,
183
190
  preferences,
184
191
  goToPage,
@@ -0,0 +1,58 @@
1
+ import { describe, it, expect, vi, beforeAll, afterEach } from 'vitest';
2
+ import { SearchMinisearch } from './SearchMinisearch';
3
+
4
+ vi.mock('minisearch', () => {
5
+ return {
6
+ default: vi.fn().mockImplementation(() => ({
7
+ addAll: vi.fn(),
8
+ search: vi.fn(),
9
+ })),
10
+ };
11
+ });
12
+
13
+ vi.mock('./melauto', () => ({
14
+ applyMelauto: vi.fn(),
15
+ }));
16
+
17
+ describe('SearchMinisearch', () => {
18
+ let searchInstance: SearchMinisearch<any>;
19
+ const mockData = [
20
+ { id: '1', label: 'First Item' },
21
+ { id: '2', label: 'Second Item' },
22
+ ];
23
+
24
+ beforeAll(() => {
25
+ searchInstance = new SearchMinisearch({
26
+ name: 'test-suggester',
27
+ fields: [{ name: 'id' }, { name: 'label' }],
28
+ queryParser: {
29
+ type: 'tokenized',
30
+ params: { language: 'English', pattern: '\\w+', min: 1 },
31
+ },
32
+ max: 10,
33
+ });
34
+ });
35
+
36
+ afterEach(() => {
37
+ const miniSearchMock = searchInstance.db as any;
38
+ miniSearchMock.addAll.mockClear();
39
+ });
40
+
41
+ it('should initialize and index data correctly', async () => {
42
+ await searchInstance.index(mockData);
43
+
44
+ // Check if MiniSearch instance was created and indexed
45
+ expect(searchInstance.db).not.toBeNull();
46
+ expect(searchInstance.isIndexed()).toBe(true);
47
+
48
+ // Check if addAll was called with the correct data
49
+ expect(searchInstance.db?.addAll).toHaveBeenCalledWith(mockData);
50
+ });
51
+
52
+ it('should not re-index if already indexed', async () => {
53
+ searchInstance.indexed = true;
54
+ await searchInstance.index(mockData);
55
+
56
+ expect(searchInstance.db?.addAll).not.toHaveBeenCalled();
57
+ });
58
+ });