@inseefr/lunatic 0.3.5-experimental → 0.3.8-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 (98) hide show
  1. package/lib/index.js +6 -6
  2. package/lib/index.js.map +1 -1
  3. package/package.json +4 -3
  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 +5 -3
  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/loop-and-controls.json +481 -0
  28. package/src/stories/questionnaire/questionnaire.stories.js +31 -0
  29. package/src/stories/suggester/bailleurs-sociaux-2021/fetch-bailleurs.js +12 -0
  30. package/src/stories/suggester/bailleurs-sociaux-2021/index.js +1 -0
  31. package/src/stories/suggester/data.json +31 -1
  32. package/src/stories/suggester/suggester-workers.stories.js +44 -0
  33. package/src/stories/suggester/suggester.stories.js +5 -0
  34. package/src/stories/utils/custom-lunatic.scss +23 -23
  35. package/src/tests/components/breadcrumb.spec.js +13 -13
  36. package/src/tests/components/button.spec.js +11 -11
  37. package/src/tests/components/checkbox-boolean.spec.js +45 -45
  38. package/src/tests/components/checkbox-group.spec.js +53 -53
  39. package/src/tests/components/checkbox-one.spec.js +32 -32
  40. package/src/tests/components/datepicker.spec.js +22 -22
  41. package/src/tests/components/declarations-wrappers/input-declarations-wrapper.spec.js +67 -67
  42. package/src/tests/components/declarations-wrappers/list-declarations-wrapper.spec.js +52 -52
  43. package/src/tests/components/declarations-wrappers/simple-declarations-wrapper.spec.js +21 -21
  44. package/src/tests/components/declarations.spec.js +46 -46
  45. package/src/tests/components/input.spec.js +18 -18
  46. package/src/tests/components/loops/loop-static.json +66 -66
  47. package/src/tests/components/loops/loop.json +258 -258
  48. package/src/tests/components/loops/loop.spec.js +30 -30
  49. package/src/tests/components/loops/roster-for-loop.spec.js +18 -18
  50. package/src/tests/components/progress-bar.spec.js +15 -15
  51. package/src/tests/components/radio.spec.js +27 -27
  52. package/src/tests/components/sequence.spec.js +9 -9
  53. package/src/tests/components/subsequence.spec.js +9 -9
  54. package/src/tests/components/table.spec.js +11 -11
  55. package/src/tests/components/textarea.spec.js +18 -18
  56. package/src/tests/components/tooltip.spec.js +25 -25
  57. package/src/tests/setup/setupTests.js +4 -4
  58. package/src/tests/utils/lib/alphabet.spec.js +36 -36
  59. package/src/tests/utils/lib/array.spec.js +22 -22
  60. package/src/tests/utils/lib/checkbox/group.spec.js +72 -72
  61. package/src/tests/utils/lib/decorator/title-decorator.spec.js +12 -12
  62. package/src/tests/utils/lib/input-number.spec.js +18 -18
  63. package/src/tests/utils/lib/items-positioning.spec.js +17 -17
  64. package/src/tests/utils/lib/label-position.spec.js +22 -22
  65. package/src/tests/utils/lib/loops/bindings.spec.js +75 -75
  66. package/src/tests/utils/lib/loops/shared.spec.js +82 -82
  67. package/src/tests/utils/lib/missing/missing.spec.js +74 -74
  68. package/src/tests/utils/lib/missing/mock.js +137 -137
  69. package/src/tests/utils/lib/pagination/shared.spec.js +42 -42
  70. package/src/tests/utils/lib/responses.spec.js +64 -64
  71. package/src/tests/utils/lib/style.spec.js +26 -26
  72. package/src/tests/utils/lib/tooltip/build-response.spec.js +95 -95
  73. package/src/tests/utils/lib/tooltip/content.spec.js +109 -109
  74. package/src/tests/utils/to-expose/handler/handler.spec.js +94 -94
  75. package/src/tests/utils/to-expose/handler/questionnaire.json +158 -158
  76. package/src/tests/utils/to-expose/handler/results/index.js +6 -6
  77. package/src/tests/utils/to-expose/handler/results/res-double.json +158 -158
  78. package/src/tests/utils/to-expose/handler/results/res-input-collected.json +158 -158
  79. package/src/tests/utils/to-expose/handler/results/res-loop.json +158 -158
  80. package/src/tests/utils/to-expose/handler/results/res-matrix.json +158 -158
  81. package/src/tests/utils/to-expose/handler/results/res-responses.json +158 -158
  82. package/src/tests/utils/to-expose/hooks/use-lunatic.spec.js +46 -46
  83. package/src/tests/utils/to-expose/init-questionnaire/data.json +12 -12
  84. package/src/tests/utils/to-expose/init-questionnaire/init-questionnaire.spec.js +19 -19
  85. package/src/tests/utils/to-expose/interpret/interpret.spec.js +48 -48
  86. package/src/tests/utils/to-expose/state/questionnaire.json +61 -61
  87. package/src/tests/utils/to-expose/state/results.js +78 -78
  88. package/src/utils/lib/controls/utils.js +8 -2
  89. package/src/utils/lib/tooltip/build-response.js +41 -41
  90. package/src/utils/store-tools/create/index.js +1 -1
  91. package/src/utils/store-tools/create/update-store-info.js +26 -26
  92. package/src/utils/store-tools/index.js +5 -5
  93. package/src/utils/suggester-workers/commons-tokenizer/create-fields-tokenizer.js +5 -1
  94. package/src/utils/suggester-workers/commons-tokenizer/index.js +1 -0
  95. package/src/utils/suggester-workers/searching/query-parser/query-parser-tokenized.js +7 -1
  96. package/src/utils/to-expose/handler.js +12 -14
  97. package/src/utils/to-expose/hooks/lunatic-split.js +5 -2
  98. package/src/utils/to-expose/hooks/lunatic.js +5 -2
@@ -0,0 +1,481 @@
1
+ {
2
+ "variables": [
3
+ {
4
+ "variableType": "COLLECTED",
5
+ "values": {
6
+ "COLLECTED": null,
7
+ "EDITED": null,
8
+ "INPUTED": null,
9
+ "FORCED": null,
10
+ "PREVIOUS": null
11
+ },
12
+ "name": "COMMENT_QE",
13
+ "componentRef": "COMMENT-QUESTION"
14
+ },
15
+ {
16
+ "variableType": "COLLECTED",
17
+ "values": {
18
+ "COLLECTED": null,
19
+ "EDITED": null,
20
+ "INPUTED": null,
21
+ "FORCED": null,
22
+ "PREVIOUS": null
23
+ },
24
+ "name": "NB",
25
+ "componentRef": "kwupqy19"
26
+ },
27
+ {
28
+ "variableType": "COLLECTED",
29
+ "values": {
30
+ "COLLECTED": [null],
31
+ "EDITED": [null],
32
+ "INPUTED": [null],
33
+ "FORCED": [null],
34
+ "PREVIOUS": [null]
35
+ },
36
+ "name": "PRENOM",
37
+ "componentRef": "kx06be0c"
38
+ },
39
+ {
40
+ "variableType": "COLLECTED",
41
+ "values": {
42
+ "COLLECTED": [null],
43
+ "EDITED": [null],
44
+ "INPUTED": [null],
45
+ "FORCED": [null],
46
+ "PREVIOUS": [null]
47
+ },
48
+ "name": "AGE",
49
+ "componentRef": "kx06be0c"
50
+ },
51
+ {
52
+ "variableType": "COLLECTED",
53
+ "values": {
54
+ "COLLECTED": null,
55
+ "EDITED": null,
56
+ "INPUTED": null,
57
+ "FORCED": null,
58
+ "PREVIOUS": null
59
+ },
60
+ "name": "Q1",
61
+ "componentRef": "kx05sq4y"
62
+ },
63
+ {
64
+ "variableType": "COLLECTED",
65
+ "values": {
66
+ "COLLECTED": null,
67
+ "EDITED": null,
68
+ "INPUTED": null,
69
+ "FORCED": null,
70
+ "PREVIOUS": null
71
+ },
72
+ "name": "Q2",
73
+ "componentRef": "kx06v7yq"
74
+ },
75
+ {
76
+ "variableType": "CALCULATED",
77
+ "expression": "true",
78
+ "name": "FILTER_RESULT_NB",
79
+ "inFilter": "false"
80
+ },
81
+ {
82
+ "variableType": "CALCULATED",
83
+ "expression": "true",
84
+ "name": "FILTER_RESULT_PRENOM",
85
+ "inFilter": "false",
86
+ "shapeFrom": "PRENOM"
87
+ },
88
+ {
89
+ "variableType": "CALCULATED",
90
+ "expression": "true",
91
+ "name": "FILTER_RESULT_AGE",
92
+ "inFilter": "false",
93
+ "shapeFrom": "PRENOM"
94
+ },
95
+ {
96
+ "variableType": "CALCULATED",
97
+ "bindingDependencies": ["AGE"],
98
+ "expression": "if (cast(nvl(AGE,\"15\"),integer) < 14) then 0 else 1",
99
+ "name": "A1",
100
+ "inFilter": "false",
101
+ "shapeFrom": "PRENOM"
102
+ },
103
+ {
104
+ "variableType": "CALCULATED",
105
+ "bindingDependencies": ["AGE"],
106
+ "expression": "if (cast(nvl(AGE,\"0\"),integer) < 18) then \"0\" else \"1\"",
107
+ "name": "A2",
108
+ "inFilter": "false",
109
+ "shapeFrom": "PRENOM"
110
+ },
111
+ {
112
+ "variableType": "CALCULATED",
113
+ "expression": "true",
114
+ "name": "FILTER_RESULT_Q1",
115
+ "inFilter": "false"
116
+ },
117
+ {
118
+ "variableType": "CALCULATED",
119
+ "expression": "true",
120
+ "name": "FILTER_RESULT_Q2",
121
+ "inFilter": "false"
122
+ },
123
+ {
124
+ "variableType": "CALCULATED",
125
+ "bindingDependencies": ["A1", "AGE"],
126
+ "expression": "sum(A1)",
127
+ "name": "B1",
128
+ "inFilter": "false"
129
+ },
130
+ {
131
+ "variableType": "CALCULATED",
132
+ "bindingDependencies": ["A2", "AGE"],
133
+ "expression": "sum(cast(A2,integer))",
134
+ "name": "B2",
135
+ "inFilter": "false"
136
+ },
137
+ {
138
+ "variableType": "CALCULATED",
139
+ "bindingDependencies": ["B1", "AGE"],
140
+ "expression": "\"Nb de majeurs\" || cast(B1,string)",
141
+ "name": "DEC1",
142
+ "inFilter": "false"
143
+ },
144
+ {
145
+ "variableType": "CALCULATED",
146
+ "bindingDependencies": ["B2", "AGE"],
147
+ "expression": "\"Nb de majeurs\" || cast(B2,string)",
148
+ "name": "DEC2",
149
+ "inFilter": "false"
150
+ }
151
+ ],
152
+ "components": [
153
+ {
154
+ "componentType": "Sequence",
155
+ "hierarchy": {
156
+ "sequence": {
157
+ "id": "kwupyhsh",
158
+ "page": "1",
159
+ "label": "\"I - \" || \"S1\""
160
+ }
161
+ },
162
+ "conditionFilter": {
163
+ "value": "true"
164
+ },
165
+ "id": "kwupyhsh",
166
+ "page": "1",
167
+ "label": "\"I - \" || \"S1\""
168
+ },
169
+ {
170
+ "componentType": "InputNumber",
171
+ "max": 100,
172
+ "hierarchy": {
173
+ "sequence": {
174
+ "id": "kwupyhsh",
175
+ "page": "1",
176
+ "label": "\"I - \" || \"S1\""
177
+ }
178
+ },
179
+ "conditionFilter": {
180
+ "value": "true"
181
+ },
182
+ "label": "\"➡ 1. \" || \"NB \"",
183
+ "mandatory": false,
184
+ "declarations": [
185
+ {
186
+ "declarationType": "HELP",
187
+ "id": "kwupqy19-kx09g78a",
188
+ "label": "\"affiche\" || cast(nvl(NB,\"\"),string)",
189
+ "position": "AFTER_QUESTION_TEXT"
190
+ }
191
+ ],
192
+ "bindingDependencies": ["NB"],
193
+ "min": 0,
194
+ "response": {
195
+ "name": "NB"
196
+ },
197
+ "decimals": 0,
198
+ "id": "kwupqy19",
199
+ "page": "2"
200
+ },
201
+ {
202
+ "componentType": "Sequence",
203
+ "hierarchy": {
204
+ "sequence": {
205
+ "id": "kx06a9lq",
206
+ "page": "3",
207
+ "label": "\"II - \" || \"S2\""
208
+ }
209
+ },
210
+ "conditionFilter": {
211
+ "value": "true"
212
+ },
213
+ "id": "kx06a9lq",
214
+ "page": "3",
215
+ "label": "\"II - \" || \"S2\""
216
+ },
217
+ {
218
+ "paginatedLoop": false,
219
+ "componentType": "Loop",
220
+ "components": [
221
+ {
222
+ "componentType": "Subsequence",
223
+ "goToPage": "4",
224
+ "hierarchy": {
225
+ "sequence": {
226
+ "id": "kx06a9lq",
227
+ "page": "3",
228
+ "label": "\"II - \" || \"S2\""
229
+ },
230
+ "subSequence": {
231
+ "id": "kx061cac",
232
+ "page": "4",
233
+ "label": "SS1"
234
+ }
235
+ },
236
+ "conditionFilter": {
237
+ "value": "true"
238
+ },
239
+ "id": "kx061cac",
240
+ "page": "4",
241
+ "label": "SS1"
242
+ },
243
+ {
244
+ "componentType": "Input",
245
+ "bindingDependencies": ["PRENOM"],
246
+ "response": {
247
+ "name": "PRENOM"
248
+ },
249
+ "hierarchy": {
250
+ "sequence": {
251
+ "id": "kx06a9lq",
252
+ "page": "3",
253
+ "label": "\"II - \" || \"S2\""
254
+ },
255
+ "subSequence": {
256
+ "id": "kx061cac",
257
+ "page": "4",
258
+ "label": "SS1"
259
+ }
260
+ },
261
+ "conditionFilter": {
262
+ "value": "true"
263
+ },
264
+ "id": "kwupruv2",
265
+ "page": "4",
266
+ "label": "\"➡ 2. \" || \"PRENOM \"",
267
+ "mandatory": false,
268
+ "maxLength": 249
269
+ },
270
+ {
271
+ "componentType": "InputNumber",
272
+ "max": 99,
273
+ "hierarchy": {
274
+ "sequence": {
275
+ "id": "kx06a9lq",
276
+ "page": "3",
277
+ "label": "\"II - \" || \"S2\""
278
+ },
279
+ "subSequence": {
280
+ "id": "kx061cac",
281
+ "page": "4",
282
+ "label": "SS1"
283
+ }
284
+ },
285
+ "conditionFilter": {
286
+ "value": "true"
287
+ },
288
+ "label": "\"➡ 3. \" || \"AGE \"",
289
+ "mandatory": false,
290
+ "declarations": [
291
+ {
292
+ "declarationType": "HELP",
293
+ "id": "kx05rmm0-kx07vkyq",
294
+ "label": "\"affiche\" || cast(A1,string)",
295
+ "position": "AFTER_QUESTION_TEXT"
296
+ },
297
+ {
298
+ "declarationType": "HELP",
299
+ "id": "kx05rmm0-kx07pza5",
300
+ "label": "\"affiche\" || cast(A2,string)",
301
+ "position": "AFTER_QUESTION_TEXT"
302
+ }
303
+ ],
304
+ "bindingDependencies": ["A1", "A2", "AGE"],
305
+ "min": 0,
306
+ "response": {
307
+ "name": "AGE"
308
+ },
309
+ "decimals": 0,
310
+ "id": "kx05rmm0",
311
+ "page": "4"
312
+ }
313
+ ],
314
+ "bindingDependencies": ["A1", "A2", "PRENOM", "AGE"],
315
+ "depth": 1,
316
+ "hierarchy": {
317
+ "sequence": {
318
+ "id": "kx06a9lq",
319
+ "page": "3",
320
+ "label": "\"II - \" || \"S2\""
321
+ }
322
+ },
323
+ "conditionFilter": {
324
+ "value": "true"
325
+ },
326
+ "id": "kx06be0c",
327
+ "page": "4",
328
+ "lines": {
329
+ "min": "2",
330
+ "max": "2"
331
+ }
332
+ },
333
+ {
334
+ "componentType": "Sequence",
335
+ "hierarchy": {
336
+ "sequence": {
337
+ "id": "kx06mitx",
338
+ "page": "5",
339
+ "label": "\"III - \" || \"CONTROLE\""
340
+ }
341
+ },
342
+ "conditionFilter": {
343
+ "value": "true"
344
+ },
345
+ "id": "kx06mitx",
346
+ "page": "5",
347
+ "label": "\"III - \" || \"CONTROLE\""
348
+ },
349
+ {
350
+ "componentType": "Input",
351
+ "bindingDependencies": ["DEC1", "DEC2", "Q1"],
352
+ "response": {
353
+ "name": "Q1"
354
+ },
355
+ "hierarchy": {
356
+ "sequence": {
357
+ "id": "kx06mitx",
358
+ "page": "5",
359
+ "label": "\"III - \" || \"CONTROLE\""
360
+ }
361
+ },
362
+ "conditionFilter": {
363
+ "value": "true"
364
+ },
365
+ "id": "kx05sq4y",
366
+ "page": "6",
367
+ "label": "\"➡ 4. \" || \"Q1 \"",
368
+ "mandatory": false,
369
+ "maxLength": 249,
370
+ "declarations": [
371
+ {
372
+ "declarationType": "HELP",
373
+ "id": "kx05sq4y-kx06gnt7",
374
+ "label": "DECLA",
375
+ "position": "AFTER_QUESTION_TEXT"
376
+ },
377
+ {
378
+ "declarationType": "HELP",
379
+ "id": "kx05sq4y-kx07lqnt",
380
+ "label": "DEC1",
381
+ "position": "AFTER_QUESTION_TEXT"
382
+ },
383
+ {
384
+ "declarationType": "HELP",
385
+ "id": "kx05sq4y-kx07mx14",
386
+ "label": "DEC2",
387
+ "position": "AFTER_QUESTION_TEXT"
388
+ }
389
+ ]
390
+ },
391
+ {
392
+ "componentType": "Input",
393
+ "bindingDependencies": ["B1", "B2", "Q2"],
394
+ "response": {
395
+ "name": "Q2"
396
+ },
397
+ "hierarchy": {
398
+ "sequence": {
399
+ "id": "kx06mitx",
400
+ "page": "5",
401
+ "label": "\"III - \" || \"CONTROLE\""
402
+ }
403
+ },
404
+ "conditionFilter": {
405
+ "value": "true"
406
+ },
407
+ "id": "kx06v7yq",
408
+ "page": "7",
409
+ "label": "\"➡ 5. \" || \"Q2 \"",
410
+ "mandatory": false,
411
+ "maxLength": 249,
412
+ "declarations": [
413
+ {
414
+ "declarationType": "HELP",
415
+ "id": "kx06v7yq-kx072jlc",
416
+ "label": "\"Nb de majeurs\" || cast(B1,string)",
417
+ "position": "AFTER_QUESTION_TEXT"
418
+ },
419
+ {
420
+ "declarationType": "HELP",
421
+ "id": "kx06v7yq-kx070ql4",
422
+ "label": "DECLA",
423
+ "position": "AFTER_QUESTION_TEXT"
424
+ },
425
+ {
426
+ "declarationType": "HELP",
427
+ "id": "kx06v7yq-kx06xp0o",
428
+ "label": "\"Nb de majeurs\" || cast(B2,string)",
429
+ "position": "AFTER_QUESTION_TEXT"
430
+ }
431
+ ]
432
+ },
433
+ {
434
+ "componentType": "Sequence",
435
+ "hierarchy": {
436
+ "sequence": {
437
+ "id": "COMMENT-SEQ",
438
+ "page": "8",
439
+ "label": "\"Commentaire\""
440
+ }
441
+ },
442
+ "conditionFilter": {
443
+ "value": "true"
444
+ },
445
+ "id": "COMMENT-SEQ",
446
+ "page": "8",
447
+ "label": "\"Commentaire\""
448
+ },
449
+ {
450
+ "componentType": "Textarea",
451
+ "bindingDependencies": ["COMMENT_QE"],
452
+ "response": {
453
+ "name": "COMMENT_QE"
454
+ },
455
+ "hierarchy": {
456
+ "sequence": {
457
+ "id": "COMMENT-SEQ",
458
+ "page": "8",
459
+ "label": "\"Commentaire\""
460
+ }
461
+ },
462
+ "conditionFilter": {
463
+ "value": "true"
464
+ },
465
+ "id": "COMMENT-QUESTION",
466
+ "page": "9",
467
+ "label": "\"Avez-vous des remarques concernant l'enquête ou des commentaires ?\"",
468
+ "mandatory": false,
469
+ "maxLength": 2000
470
+ }
471
+ ],
472
+ "pagination": "question",
473
+ "lunaticModelVersion": "2.2.8",
474
+ "modele": "TESTANNE",
475
+ "enoCoreVersion": "2.3.2",
476
+ "generatingDate": "10-12-2021 12:37:32",
477
+ "missing": false,
478
+ "id": "kwupldxm",
479
+ "label": "test Anne",
480
+ "maxPage": "9"
481
+ }
@@ -10,7 +10,9 @@ import logementS2 from './logement-s2';
10
10
  import logementSequence from './logement-sequence';
11
11
  import dataLogement from './data-logement';
12
12
  import simpsons from './simpsons';
13
+ import loopAndControls from './loop-and-controls.json';
13
14
  import arithmetic from './arithmetic';
15
+ import kish from './kish';
14
16
  import arithmeticManagement from './arithmetic-management';
15
17
  import updateExternalQuestionnaire from './update-external/questionnaire';
16
18
  import updateExternalData from './update-external/data';
@@ -92,6 +94,17 @@ paginated.addWithJSX('Calculated Variables', () => (
92
94
  />
93
95
  ));
94
96
 
97
+ paginated.addWithJSX('Kish', () => (
98
+ <Orchestrator
99
+ id="props"
100
+ source={kish}
101
+ features={select('Features', featuresOptions, ['VTL', 'MD'])}
102
+ positioning={select('Items positioning', positioningOptions, 'DEFAULT')}
103
+ disabled={boolean('Disabled', false)}
104
+ pagination
105
+ />
106
+ ));
107
+
95
108
  paginated.addWithJSX('Logement', () => (
96
109
  <OrchestratorSplit
97
110
  id="props"
@@ -180,6 +193,24 @@ const other = storiesOf('Questionnaire/Other', module).addDecorator(
180
193
  }
181
194
  );
182
195
 
196
+ other.addWithJSX('Controls', () => (
197
+ <Orchestrator
198
+ id="props"
199
+ modalForControls={true}
200
+ source={loopAndControls}
201
+ missing={boolean('Missing', false)}
202
+ activeGoNextForMissing={boolean('Active go next for missing', false)}
203
+ missingShortcut={{ dontKnow: 'f2', refused: 'f4' }}
204
+ shortcut
205
+ features={select('Features', featuresOptions, ['VTL', 'MD'])}
206
+ positioning={select('Items positioning', positioningOptions, 'DEFAULT')}
207
+ disabled={boolean('Disabled', false)}
208
+ focused={boolean('Focused', false)}
209
+ management={boolean('Management', false)}
210
+ pagination
211
+ />
212
+ ));
213
+
183
214
  other.addWithJSX('Update external', () => {
184
215
  const [addExternal, setAddExternal] = useState(null);
185
216
  return (
@@ -0,0 +1,12 @@
1
+ const FILE_NAME = 'bailleurs-sociaux-2021.json';
2
+
3
+ async function fetchBailleurs(path = '') {
4
+ const sbPath =
5
+ process.env.NODE_ENV === 'development'
6
+ ? `${path}/${FILE_NAME}`
7
+ : `/Lunatic/storybook/${FILE_NAME}`;
8
+ const response = await fetch(sbPath);
9
+ return response.json();
10
+ }
11
+
12
+ export default fetchBailleurs;
@@ -0,0 +1 @@
1
+ export { default as fetch } from './fetch-bailleurs';
@@ -61,7 +61,26 @@
61
61
  "stopWords": ["de", "la", "les", "du", "et", "au", "aux", "en"],
62
62
  "max": 12,
63
63
  "version": "1"
64
- }
64
+ },{
65
+ "name": "bailleurs-sociaux-2021",
66
+ "fields": [
67
+ {
68
+ "name": "label",
69
+ "rules": ["[\\w]+"],
70
+ "stemmer": true,
71
+ "synonyms": [{ "source": "saint", "target": ["st"] }]
72
+ },
73
+
74
+ { "name": "id" }
75
+ ],
76
+ "max": 12,
77
+ "stopWords": ["de", "la", "les", "du", "et", "au", "aux", "en"],
78
+ "queryParser": {
79
+ "type": "tokenized",
80
+ "params": { "language": "French", "min": 1, "pattern": "[\\w]+" }
81
+ },
82
+ "version": "1"
83
+ }
65
84
  ],
66
85
  "components": [
67
86
  {
@@ -96,6 +115,17 @@
96
115
  "response": {
97
116
  "name": "BAILLEURS"
98
117
  }
118
+ },
119
+ {
120
+ "id": "bailleurs-sociaux-2021",
121
+ "componentType": "Suggester",
122
+ "mandatory": false,
123
+ "label": "Bailleurs sociaux 2021",
124
+ "path": "data/bailleurs-2021",
125
+ "storeName": "bailleurs-sociaux-2021",
126
+ "response": {
127
+ "name": "BAILLEURS"
128
+ }
99
129
  }
100
130
  ],
101
131
  "variables": [
@@ -15,6 +15,10 @@ function fetchNaf() {
15
15
  return fetch('naf-rev2.json').then((r) => r.json());
16
16
  }
17
17
 
18
+ function fetchBailleurs2021() {
19
+ return fetch('bailleurs-sociaux-2021.json').then((r) => r.json());
20
+ }
21
+
18
22
  async function fetchBailleurs(path = '') {
19
23
  const response = await fetch('/bailleurs-sociaux.json');
20
24
  const naf = await response.json();
@@ -86,6 +90,27 @@ const infoNaf = {
86
90
  version: '1',
87
91
  };
88
92
 
93
+ const infoBailleurs2021 = {
94
+ name: 'bailleurs-sociaux-2021',
95
+ fields: [
96
+ {
97
+ name: 'label',
98
+ rules: ['[\\w]+'],
99
+ stemmer: false,
100
+ synonyms: [{ source: 'saint', target: ['st'] }],
101
+ },
102
+
103
+ { name: 'id' },
104
+ ],
105
+ max: 12,
106
+ stopWords: ['de', 'la', 'les', 'du', 'et', 'au', 'aux', 'en'],
107
+ queryParser: {
108
+ type: 'tokenized',
109
+ params: { language: 'French', min: 1, pattern: '[\\w]+' },
110
+ },
111
+ version: '1',
112
+ };
113
+
89
114
  async function loadCog() {
90
115
  const { name } = infoCog;
91
116
  const communes = await fetchCog();
@@ -106,6 +131,16 @@ async function loadBailleurs() {
106
131
  await insertEntity(db, CONSTANTES.STORE_INFO_NAME, bailleursSociaux);
107
132
  }
108
133
 
134
+ async function loadBailleurs2021() {
135
+ const { name } = infoBailleurs2021;
136
+ const bailleurs = await fetchBailleurs2021();
137
+ const db = await openOnCreateDb(name);
138
+ await clearDb(db, CONSTANTES.STORE_DATA_NAME);
139
+ await clearDb(db, CONSTANTES.STORE_INFO_NAME);
140
+ await append(infoBailleurs2021, '1', bailleurs, console.log);
141
+ await insertEntity(db, CONSTANTES.STORE_INFO_NAME, infoBailleurs2021);
142
+ }
143
+
109
144
  async function loadNaf() {
110
145
  const { name } = infoNaf;
111
146
  const rubriques = await fetchNaf();
@@ -176,6 +211,15 @@ stories.addWithJSX('Default', () => {
176
211
  />
177
212
  <Search storeInfo={bailleursSociaux} defaultValue="123" />
178
213
  </li>
214
+
215
+ <li>
216
+ <input
217
+ type="button"
218
+ value="load bailleurs sociaux 2021"
219
+ onClick={loadBailleurs2021}
220
+ />
221
+ <Search storeInfo={infoBailleurs2021} defaultValue="" />
222
+ </li>
179
223
  </ul>
180
224
  </>
181
225
  );
@@ -13,6 +13,7 @@ import { SuggesterLoaderWidget } from 'components';
13
13
  import * as NAF from './naf-rev2';
14
14
  import * as COG from './cog-communes';
15
15
  import * as BAILLEURS from './bailleurs-sociaux';
16
+ import * as BAILLEURS2021 from './bailleurs-sociaux-2021';
16
17
 
17
18
  /**
18
19
  *
@@ -24,6 +25,8 @@ function getSuggesterInfo(name) {
24
25
  return { optionRenderer: COG.OptionRenderer, idbVersion: '1' };
25
26
  } else if (name === 'bailleurs-sociaux') {
26
27
  return { optionRenderer: BAILLEURS.OptionRenderer, idbVersion: '1' };
28
+ } else if (name === 'bailleurs-sociaux-2021') {
29
+ return { idbVersion: '1' };
27
30
  }
28
31
  console.warn(`Unknown store : ${name}`);
29
32
  return {};
@@ -39,6 +42,8 @@ function getWidgetLoaderInfo(name) {
39
42
  return { fetch: COG.fetch, idbVersion: '1' };
40
43
  } else if (name === 'bailleurs-sociaux') {
41
44
  return { fetch: BAILLEURS.fetch, idbVersion: '1' };
45
+ } else if (name === 'bailleurs-sociaux-2021') {
46
+ return { fetch: BAILLEURS2021.fetch, idbVersion: '1' };
42
47
  }
43
48
  console.warn(`Unknown store : ${name}`);
44
49
  return {};