@inseefr/lunatic 0.1.0-hackathon → 0.1.0-v2

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 (350) hide show
  1. package/lib/index.js +1433 -835
  2. package/lib/index.js.map +1 -1
  3. package/package.json +11 -8
  4. package/src/components/breadcrumb/component.js +29 -29
  5. package/src/components/button/index.js +1 -1
  6. package/src/components/button/lunatic-button.js +32 -0
  7. package/src/components/checkbox/checkbox-boolean/index.js +1 -0
  8. package/src/components/checkbox/checkbox-boolean/lunatic-checkbox-boolean.js +44 -0
  9. package/src/components/checkbox/checkbox-group/checkbox-group.js +78 -0
  10. package/src/components/checkbox/checkbox-group/checkbox-option.js +46 -0
  11. package/src/components/checkbox/checkbox-group/index.js +1 -0
  12. package/src/components/checkbox/checkbox-group/lunatic-checkbox-group.js +32 -0
  13. package/src/components/checkbox/checkbox-one/index.js +1 -0
  14. package/src/components/checkbox/checkbox-one/lunatic-checkbox-one.js +7 -0
  15. package/src/components/checkbox/checkbox.scss +1 -73
  16. package/src/components/checkbox/commons/checkbox-option.js +49 -0
  17. package/src/components/checkbox/commons/index.js +1 -0
  18. package/src/components/checkbox/index.js +3 -3
  19. package/src/components/commons/components/field-container/field-container.js +28 -0
  20. package/src/components/commons/components/field-container/field-container.scss +0 -0
  21. package/src/components/commons/components/field-container/index.js +1 -0
  22. package/src/components/commons/components/fieldset.js +12 -0
  23. package/src/components/commons/components/input-container.js +30 -0
  24. package/src/components/commons/components/label.js +14 -0
  25. package/src/components/commons/components/lunatic-field.js +35 -0
  26. package/src/components/commons/create-customizable-field.js +13 -0
  27. package/src/components/commons/index.js +9 -0
  28. package/src/components/commons/use-on-handle-change.js +16 -0
  29. package/src/components/commons/use-options-keydown.js +22 -0
  30. package/src/components/commons/use-previous.js +11 -0
  31. package/src/components/component-wrapper/controls/component.js +70 -0
  32. package/src/components/component-wrapper/controls/controls.scss +6 -0
  33. package/src/components/component-wrapper/controls/index.js +1 -0
  34. package/src/components/component-wrapper/controls/validators/datepicker.js +33 -0
  35. package/src/components/component-wrapper/controls/validators/index.js +16 -0
  36. package/src/components/component-wrapper/controls/validators/input-number.js +23 -0
  37. package/src/components/{missing-wrapper → component-wrapper}/index.js +1 -1
  38. package/src/components/{missing-wrapper → component-wrapper/missing}/component.js +72 -12
  39. package/src/components/component-wrapper/missing/index.js +1 -0
  40. package/src/components/{missing-wrapper → component-wrapper/missing}/missing.scss +0 -0
  41. package/src/components/component-wrapper/wrapper.js +23 -0
  42. package/src/components/components.js +22 -18
  43. package/src/components/datepicker/datepicker.js +25 -0
  44. package/src/components/datepicker/index.js +1 -1
  45. package/src/components/datepicker/lunatic-datepicker.js +50 -0
  46. package/src/components/declarations/declaration.js +11 -0
  47. package/src/components/declarations/declarations-after-text.js +8 -0
  48. package/src/components/declarations/declarations-before-text.js +8 -0
  49. package/src/components/declarations/declarations-detachable.js +8 -0
  50. package/src/components/declarations/declarations.js +35 -0
  51. package/src/components/declarations/index.js +4 -1
  52. package/src/components/declarations/wrappers/input-declarations-wrapper.js +40 -12
  53. package/src/components/declarations/wrappers/list-declarations-wrapper.js +235 -232
  54. package/src/components/dropdown/commons/actions.js +40 -31
  55. package/src/components/dropdown/commons/components/panel.js +78 -78
  56. package/src/components/dropdown/commons/reducer.js +152 -149
  57. package/src/components/dropdown/component.js +121 -115
  58. package/src/components/dropdown/dropdown-edit/dropdown-edit.js +6 -0
  59. package/src/components/dropdown/dropdown-simple/dropdown.js +8 -1
  60. package/src/components/filter-description/component.js +48 -42
  61. package/src/components/icon/component.js +31 -33
  62. package/src/components/index.scss +5 -3
  63. package/src/components/input/index.js +1 -2
  64. package/src/components/input/input.js +45 -9
  65. package/src/components/input/input.scss +0 -6
  66. package/src/components/input/lunatic-input.js +53 -0
  67. package/src/components/input-number/index.js +1 -0
  68. package/src/components/input-number/input-number.js +38 -0
  69. package/src/components/input-number/input-number.scss +0 -0
  70. package/src/components/input-number/lunatic-input-number.js +50 -0
  71. package/src/components/loop/{component.js → _old/component.js} +1 -0
  72. package/src/components/loop/{loop.scss → _old/loop.scss} +0 -0
  73. package/src/components/loop/{wrapper.js → _old/wrapper.js} +15 -15
  74. package/src/components/loop/block-for-loop/block-for-loop-ochestrator.js +6 -0
  75. package/src/components/loop/block-for-loop/block-for-loop.js +91 -0
  76. package/src/components/loop/block-for-loop/index.js +1 -0
  77. package/src/components/loop/block-for-loop/row.js +52 -0
  78. package/src/components/loop/commons/create-loop-orchestrator.js +36 -0
  79. package/src/components/loop/commons/index.js +2 -0
  80. package/src/components/loop/commons/row-component.js +52 -0
  81. package/src/components/loop/index.js +1 -1
  82. package/src/components/loop/loop.js +78 -0
  83. package/src/components/loop/roster-for-loop/add-row-button.js +12 -0
  84. package/src/components/loop/roster-for-loop/body.js +44 -0
  85. package/src/components/loop/roster-for-loop/header.js +25 -0
  86. package/src/components/loop/roster-for-loop/html-table/table.js +11 -0
  87. package/src/components/loop/roster-for-loop/html-table/tbody.js +11 -0
  88. package/src/components/loop/roster-for-loop/html-table/td.js +14 -0
  89. package/src/components/loop/roster-for-loop/html-table/th.js +11 -0
  90. package/src/components/loop/roster-for-loop/html-table/thead.js +11 -0
  91. package/src/components/loop/roster-for-loop/html-table/tr.js +11 -0
  92. package/src/components/loop/roster-for-loop/index.js +1 -0
  93. package/src/components/loop/roster-for-loop/roster-for-loop-orchestrator.js +6 -0
  94. package/src/components/loop/roster-for-loop/roster-for-loop.js +90 -0
  95. package/src/components/loop/roster-for-loop/roster-table.js +39 -0
  96. package/src/components/loop/roster-for-loop/roster.scss +42 -0
  97. package/src/components/loop/roster-for-loop/row.js +65 -0
  98. package/src/components/loop-constructor/block/component.js +2 -2
  99. package/src/components/loop-constructor/block/index.js +1 -1
  100. package/src/components/loop-constructor/index.js +1 -1
  101. package/src/components/loop-constructor/roster/component.js +2 -2
  102. package/src/components/loop-constructor/roster/index.js +1 -1
  103. package/src/components/loop-constructor/wrapper/body-component.js +6 -0
  104. package/src/components/loop-constructor/wrapper/build-components.js +33 -33
  105. package/src/components/loop-constructor/wrapper/index.js +1 -1
  106. package/src/components/modal/component.js +42 -0
  107. package/src/components/modal/index.js +1 -0
  108. package/src/components/modal/modal.scss +33 -0
  109. package/src/components/radio/index.js +1 -1
  110. package/src/components/radio/lunatic-radio-group.js +45 -0
  111. package/src/components/radio/radio-group.js +33 -0
  112. package/src/components/radio/radio-option.js +87 -0
  113. package/src/components/radio/radio.scss +52 -52
  114. package/src/components/sequence/index.js +1 -1
  115. package/src/components/sequence/sequence.js +75 -0
  116. package/src/components/subsequence/index.js +1 -1
  117. package/src/components/subsequence/subsequence.js +73 -0
  118. package/src/components/suggester/check-store.js +70 -70
  119. package/src/components/suggester/components/panel/option-container.js +11 -10
  120. package/src/components/suggester/components/panel/panel.js +20 -6
  121. package/src/components/suggester/components/selection/label.js +7 -6
  122. package/src/components/suggester/components/selection/selection.js +36 -11
  123. package/src/components/suggester/components/suggester-content.js +35 -42
  124. package/src/components/suggester/components/suggester.js +45 -26
  125. package/src/components/suggester/{components/create-on-keydown-callback.js → create-on-keydown-callback.js} +28 -28
  126. package/src/components/suggester/find-best-label/find-best-label.js +3 -1
  127. package/src/components/suggester/idb-suggester.js +2 -1
  128. package/src/components/suggester/lunatic-suggester.js +48 -96
  129. package/src/components/suggester/searching/create-searching.js +3 -1
  130. package/src/components/suggester/suggester-wrapper.js +75 -9
  131. package/src/components/switch/index.js +1 -0
  132. package/src/components/switch/lunatic-switch.js +49 -0
  133. package/src/components/switch/switch.js +72 -0
  134. package/src/components/switch/switch.scss +47 -0
  135. package/src/components/table/table.js +164 -158
  136. package/src/components/textarea/component.js +11 -5
  137. package/src/components/tooltip/response.js +58 -52
  138. package/src/stories/checkbox-boolean/data-forced.json +48 -48
  139. package/src/stories/checkbox-group/data-vtl.json +102 -102
  140. package/src/stories/cleaning/cleaning.stories.js +39 -0
  141. package/src/stories/cleaning/simple-loop.json +911 -0
  142. package/src/stories/cleaning/simpsons.json +5839 -0
  143. package/src/stories/datepicker/data.json +45 -43
  144. package/src/stories/declarations/declarations.stories.js +20 -13
  145. package/src/stories/icons/icons.stories.js +24 -16
  146. package/src/stories/loop-constructor/README.md +27 -27
  147. package/src/stories/loop-constructor/data-input-forced.json +64 -64
  148. package/src/stories/loop-constructor/data-input.json +100 -100
  149. package/src/stories/loop-constructor/data-loop-forced.json +66 -66
  150. package/src/stories/loop-constructor/data-loop-static-forced.json +66 -66
  151. package/src/stories/loop-constructor/data-loop-static.json +81 -81
  152. package/src/stories/loop-constructor/data-loop.json +81 -81
  153. package/src/stories/loop-constructor/data-roster-forced.json +68 -68
  154. package/src/stories/loop-constructor/data-roster.json +83 -83
  155. package/src/stories/loop-constructor/loop-constructor.stories.js +180 -180
  156. package/src/stories/questionnaire/logement-queen.json +23234 -0
  157. package/src/stories/questionnaire/logement.json +22068 -26812
  158. package/src/stories/questionnaire/questionnaire.stories.js +86 -29
  159. package/src/stories/questionnaire/update-external/data.json +1 -0
  160. package/src/stories/questionnaire/update-external/questionnaire.json +75 -0
  161. package/src/stories/suggester/bailleurs-sociaux-2021/fetch-bailleurs.js +12 -0
  162. package/src/stories/suggester/bailleurs-sociaux-2021/index.js +1 -0
  163. package/src/stories/suggester/data-auto.json +1 -0
  164. package/src/stories/suggester/data.json +35 -2
  165. package/src/stories/suggester/lunatic-suggester-mui.scss +27 -0
  166. package/src/stories/suggester/suggester-material-ui.js +148 -0
  167. package/src/stories/suggester/suggester-workers.stories.js +48 -1
  168. package/src/stories/suggester/suggester.stories.js +27 -1
  169. package/src/stories/switch/README.md +31 -0
  170. package/src/stories/switch/SwitchMaterialUI.js +35 -0
  171. package/src/stories/switch/data-forced.json +48 -0
  172. package/src/stories/switch/data.json +80 -0
  173. package/src/stories/switch/switch.stories.js +78 -0
  174. package/src/stories/utils/custom-lunatic.scss +28 -23
  175. package/src/stories/utils/orchestrator.js +151 -58
  176. package/src/stories/utils/waiting/index.js +1 -0
  177. package/src/stories/utils/waiting/preloader.svg +1 -0
  178. package/src/stories/utils/waiting/waiting.js +21 -0
  179. package/src/stories/utils/waiting/waiting.scss +21 -0
  180. package/src/tests/sample.spec.js +5 -0
  181. package/src/utils/icons/checkbox-checked.icon.js +25 -0
  182. package/src/utils/icons/checkbox-unchecked.icon.js +25 -0
  183. package/src/utils/icons/radio-checked.icon.js +25 -0
  184. package/src/utils/icons/radio-unchecked.icon.js +25 -0
  185. package/src/utils/lib/controls/index.js +1 -0
  186. package/src/utils/lib/controls/utils.js +146 -0
  187. package/src/utils/lib/index.js +20 -19
  188. package/src/utils/lib/pagination/navigation/shared.js +7 -4
  189. package/src/utils/lib/responses.js +9 -7
  190. package/src/utils/lib/tooltip/build-response.js +53 -41
  191. package/src/utils/store-tools/auto-load.js +2 -1
  192. package/src/utils/store-tools/create/index.js +2 -1
  193. package/src/utils/store-tools/create/update-store-info.js +26 -26
  194. package/src/utils/store-tools/index.js +7 -5
  195. package/src/utils/suggester-workers/append-to-index/create-append-task.js +3 -1
  196. package/src/utils/suggester-workers/commons-tokenizer/create-entity-tokenizer.js +56 -0
  197. package/src/utils/suggester-workers/commons-tokenizer/create-fields-tokenizer.js +56 -0
  198. package/src/utils/suggester-workers/commons-tokenizer/create-filter-stop-words.js +11 -11
  199. package/src/utils/suggester-workers/commons-tokenizer/filters/compose-filters.js +10 -0
  200. package/src/utils/suggester-workers/commons-tokenizer/filters/create-filter-stop-words.js +17 -0
  201. package/src/utils/suggester-workers/commons-tokenizer/filters/create-filter-stop-words.spec.js +14 -0
  202. package/src/utils/suggester-workers/commons-tokenizer/filters/filter-accents.js +12 -0
  203. package/src/utils/suggester-workers/commons-tokenizer/filters/filter-accents.spec.js +12 -0
  204. package/src/utils/suggester-workers/commons-tokenizer/{filter-double.js → filters/filter-double.js} +0 -0
  205. package/src/utils/suggester-workers/commons-tokenizer/filters/filter-double.spec.js +20 -0
  206. package/src/utils/suggester-workers/commons-tokenizer/{filter-length.js → filters/filter-length.js} +0 -0
  207. package/src/utils/suggester-workers/commons-tokenizer/filters/filter-length.spec.js +18 -0
  208. package/src/utils/suggester-workers/commons-tokenizer/{filter-stemmer.js → filters/filter-stemmer.js} +2 -2
  209. package/src/utils/suggester-workers/commons-tokenizer/filters/filter-stemmer.spec.js +12 -0
  210. package/src/utils/suggester-workers/commons-tokenizer/filters/filter-synonyms.js +36 -0
  211. package/src/utils/suggester-workers/commons-tokenizer/filters/filter-synonyms.spec.js +12 -0
  212. package/src/utils/suggester-workers/commons-tokenizer/filters/filter-to-lower.js +10 -0
  213. package/src/utils/suggester-workers/commons-tokenizer/filters/filter-to-lower.spec.js +12 -0
  214. package/src/utils/suggester-workers/commons-tokenizer/filters/index.js +2 -0
  215. package/src/utils/suggester-workers/commons-tokenizer/{stop-words.js → filters/stop-words.js} +0 -0
  216. package/src/utils/suggester-workers/commons-tokenizer/index.js +6 -5
  217. package/src/utils/suggester-workers/commons-tokenizer/prepare-string-indexation.js +7 -3
  218. package/src/utils/suggester-workers/commons-tokenizer/soft-tokenizer.js +1 -1
  219. package/src/utils/suggester-workers/create-worker.js +55 -0
  220. package/src/utils/suggester-workers/find-best-label/tokenize.js +2 -5
  221. package/src/utils/suggester-workers/{query-parser → searching/query-parser}/index.js +0 -0
  222. package/src/utils/suggester-workers/searching/query-parser/query-parser-soft.js +7 -0
  223. package/src/utils/suggester-workers/{query-parser → searching/query-parser}/query-parser-soft.spec.js +0 -0
  224. package/src/utils/suggester-workers/searching/query-parser/query-parser-tokenized.js +34 -0
  225. package/src/utils/suggester-workers/searching/resolve-query-parser.js +2 -2
  226. package/src/utils/suggester-workers/searching/searching.js +2 -2
  227. package/src/utils/to-expose/{calculated-variables.js → _old/calculated-variables.js} +0 -0
  228. package/src/utils/to-expose/{handler.js → _old/handler.js} +22 -0
  229. package/src/utils/to-expose/{init-questionnaire.js → _old/init-questionnaire.js} +0 -0
  230. package/src/utils/to-expose/{state.js → _old/state.js} +13 -14
  231. package/src/utils/to-expose/hooks/filter-components.js +106 -106
  232. package/src/utils/to-expose/hooks/index.js +1 -1
  233. package/src/utils/to-expose/hooks/lunatic.js +68 -7
  234. package/src/utils/to-expose/hooks/use-lunatic/actions.js +23 -0
  235. package/src/utils/to-expose/hooks/use-lunatic/commons/check-loops.js +61 -0
  236. package/src/utils/to-expose/hooks/use-lunatic/commons/create-map-pages.js +69 -0
  237. package/src/utils/to-expose/hooks/use-lunatic/commons/execute-condition-filter.js +16 -0
  238. package/src/utils/to-expose/hooks/use-lunatic/commons/execute-expression/create-execute-expression.js +182 -0
  239. package/src/utils/to-expose/hooks/use-lunatic/commons/execute-expression/create-memoizer.js +42 -0
  240. package/src/utils/to-expose/hooks/use-lunatic/commons/execute-expression/create-refresh-calculated.js +50 -0
  241. package/src/utils/to-expose/hooks/use-lunatic/commons/execute-expression/execute-expression.js +60 -0
  242. package/src/utils/to-expose/hooks/use-lunatic/commons/execute-expression/get-expressions-variables.js +22 -0
  243. package/src/utils/to-expose/hooks/use-lunatic/commons/execute-expression/index.js +1 -0
  244. package/src/utils/to-expose/hooks/use-lunatic/commons/fill-component-expressions.js +113 -0
  245. package/src/utils/to-expose/hooks/use-lunatic/commons/fill-components.js +31 -0
  246. package/src/utils/to-expose/hooks/use-lunatic/commons/get-compatible-vtl-expression.js +14 -0
  247. package/src/utils/to-expose/hooks/use-lunatic/commons/get-component-value/get-component-value.js +161 -0
  248. package/src/utils/to-expose/hooks/use-lunatic/commons/get-component-value/index.js +1 -0
  249. package/src/utils/to-expose/hooks/use-lunatic/commons/get-components-from-state.js +24 -0
  250. package/src/utils/to-expose/hooks/use-lunatic/commons/get-page-tag.js +10 -0
  251. package/src/utils/to-expose/hooks/use-lunatic/commons/index.js +12 -0
  252. package/src/utils/to-expose/hooks/use-lunatic/commons/is-First-last-page.js +8 -0
  253. package/src/utils/to-expose/hooks/use-lunatic/commons/is-paginated-loop.js +6 -0
  254. package/src/utils/to-expose/hooks/use-lunatic/commons/load-suggesters.js +59 -0
  255. package/src/utils/to-expose/hooks/use-lunatic/commons/use-components-from-state.js +20 -0
  256. package/src/utils/to-expose/hooks/use-lunatic/index.js +1 -0
  257. package/src/utils/to-expose/hooks/use-lunatic/initial-state.js +22 -0
  258. package/src/utils/to-expose/hooks/use-lunatic/reducer/commons/index.js +3 -0
  259. package/src/utils/to-expose/hooks/use-lunatic/reducer/commons/is-empty-on-empty-page.js +29 -0
  260. package/src/utils/to-expose/hooks/use-lunatic/reducer/commons/resize-array-variable.js +26 -0
  261. package/src/utils/to-expose/hooks/use-lunatic/reducer/commons/validate-loop-condition-filter.js +20 -0
  262. package/src/utils/to-expose/hooks/use-lunatic/reducer/index.js +1 -0
  263. package/src/utils/to-expose/hooks/use-lunatic/reducer/reduce-go-next-page.js +129 -0
  264. package/src/utils/to-expose/hooks/use-lunatic/reducer/reduce-go-previous-page.js +131 -0
  265. package/src/utils/to-expose/hooks/use-lunatic/reducer/reduce-handle-change/index.js +1 -0
  266. package/src/utils/to-expose/hooks/use-lunatic/reducer/reduce-handle-change/reduce-handle-change.js +69 -0
  267. package/src/utils/to-expose/hooks/use-lunatic/reducer/reduce-handle-change/reduce-variables-array.js +22 -0
  268. package/src/utils/to-expose/hooks/use-lunatic/reducer/reduce-handle-change/reduce-variables-simple.js +13 -0
  269. package/src/utils/to-expose/hooks/use-lunatic/reducer/reduce-on-init.js +166 -0
  270. package/src/utils/to-expose/hooks/use-lunatic/reducer/reduce-on-set-waiting.js +7 -0
  271. package/src/utils/to-expose/hooks/use-lunatic/reducer/reducer.js +26 -0
  272. package/src/utils/to-expose/hooks/use-lunatic/use-lunatic.js +79 -0
  273. package/src/utils/to-expose/index.js +16 -11
  274. package/src/components/button/component.js +0 -53
  275. package/src/components/checkbox/boolean.js +0 -172
  276. package/src/components/checkbox/group.js +0 -231
  277. package/src/components/checkbox/one.js +0 -11
  278. package/src/components/datepicker/component.js +0 -11
  279. package/src/components/input/input-number.js +0 -54
  280. package/src/components/missing-wrapper/wrapper.js +0 -10
  281. package/src/components/radio/component.js +0 -9
  282. package/src/components/sequence/component.js +0 -50
  283. package/src/components/subsequence/component.js +0 -49
  284. package/src/tests/components/breadcrumb.spec.js +0 -13
  285. package/src/tests/components/button.spec.js +0 -11
  286. package/src/tests/components/checkbox-boolean.spec.js +0 -45
  287. package/src/tests/components/checkbox-group.spec.js +0 -53
  288. package/src/tests/components/checkbox-one.spec.js +0 -32
  289. package/src/tests/components/datepicker.spec.js +0 -22
  290. package/src/tests/components/declarations-wrappers/input-declarations-wrapper.spec.js +0 -67
  291. package/src/tests/components/declarations-wrappers/list-declarations-wrapper.spec.js +0 -52
  292. package/src/tests/components/declarations-wrappers/simple-declarations-wrapper.spec.js +0 -21
  293. package/src/tests/components/declarations.spec.js +0 -46
  294. package/src/tests/components/input-number.spec.js +0 -194
  295. package/src/tests/components/input.spec.js +0 -18
  296. package/src/tests/components/loops/loop-static.json +0 -66
  297. package/src/tests/components/loops/loop.json +0 -258
  298. package/src/tests/components/loops/loop.spec.js +0 -30
  299. package/src/tests/components/loops/roster-for-loop.spec.js +0 -18
  300. package/src/tests/components/loops/roster-loop.json +0 -71
  301. package/src/tests/components/missing-wrapper.spec.js +0 -33
  302. package/src/tests/components/progress-bar.spec.js +0 -15
  303. package/src/tests/components/radio.spec.js +0 -27
  304. package/src/tests/components/sequence.spec.js +0 -9
  305. package/src/tests/components/subsequence.spec.js +0 -9
  306. package/src/tests/components/table.spec.js +0 -11
  307. package/src/tests/components/textarea.spec.js +0 -18
  308. package/src/tests/components/tooltip.spec.js +0 -25
  309. package/src/tests/setup/setupTests.js +0 -4
  310. package/src/tests/utils/lib/alphabet.spec.js +0 -36
  311. package/src/tests/utils/lib/array.spec.js +0 -22
  312. package/src/tests/utils/lib/checkbox/group.spec.js +0 -72
  313. package/src/tests/utils/lib/decorator/title-decorator.spec.js +0 -12
  314. package/src/tests/utils/lib/input-number.spec.js +0 -18
  315. package/src/tests/utils/lib/items-positioning.spec.js +0 -17
  316. package/src/tests/utils/lib/label-position.spec.js +0 -22
  317. package/src/tests/utils/lib/loops/bindings.spec.js +0 -75
  318. package/src/tests/utils/lib/loops/shared.spec.js +0 -82
  319. package/src/tests/utils/lib/missing/missing.spec.js +0 -74
  320. package/src/tests/utils/lib/missing/mock.js +0 -137
  321. package/src/tests/utils/lib/pagination/shared.spec.js +0 -42
  322. package/src/tests/utils/lib/responses.spec.js +0 -64
  323. package/src/tests/utils/lib/style.spec.js +0 -26
  324. package/src/tests/utils/lib/table/roster.spec.js +0 -25
  325. package/src/tests/utils/lib/tooltip/build-response.spec.js +0 -95
  326. package/src/tests/utils/lib/tooltip/content.spec.js +0 -109
  327. package/src/tests/utils/to-expose/handler/handler.spec.js +0 -94
  328. package/src/tests/utils/to-expose/handler/questionnaire.json +0 -158
  329. package/src/tests/utils/to-expose/handler/results/index.js +0 -6
  330. package/src/tests/utils/to-expose/handler/results/res-double.json +0 -158
  331. package/src/tests/utils/to-expose/handler/results/res-input-collected.json +0 -158
  332. package/src/tests/utils/to-expose/handler/results/res-input-edited.json +0 -158
  333. package/src/tests/utils/to-expose/handler/results/res-loop.json +0 -158
  334. package/src/tests/utils/to-expose/handler/results/res-matrix.json +0 -158
  335. package/src/tests/utils/to-expose/handler/results/res-responses.json +0 -158
  336. package/src/tests/utils/to-expose/hooks/use-lunatic.spec.js +0 -46
  337. package/src/tests/utils/to-expose/init-questionnaire/data.json +0 -12
  338. package/src/tests/utils/to-expose/init-questionnaire/init-questionnaire.spec.js +0 -19
  339. package/src/tests/utils/to-expose/init-questionnaire/questionnaire.json +0 -148
  340. package/src/tests/utils/to-expose/init-questionnaire/result.json +0 -181
  341. package/src/tests/utils/to-expose/interpret/interpret.spec.js +0 -48
  342. package/src/tests/utils/to-expose/state/questionnaire.json +0 -61
  343. package/src/tests/utils/to-expose/state/results.js +0 -78
  344. package/src/tests/utils/to-expose/state/state.spec.js +0 -59
  345. package/src/utils/suggester-workers/commons-tokenizer/create-tokenizer.js +0 -103
  346. package/src/utils/suggester-workers/commons-tokenizer/filter-accents-to-lower.js +0 -9
  347. package/src/utils/suggester-workers/commons-tokenizer/filter-synonyms.js +0 -10
  348. package/src/utils/suggester-workers/query-parser/query-parser-soft.js +0 -7
  349. package/src/utils/suggester-workers/query-parser/query-parser-tokenized.js +0 -31
  350. package/src/utils/suggester-workers/query-parser/query-parser-tokenized.spec.js +0 -32
@@ -1,14 +1,17 @@
1
- import React from 'react';
1
+ import React, { useState } from 'react';
2
2
  import { storiesOf } from '@storybook/react';
3
3
  import Orchestrator from '../utils/orchestrator';
4
4
  import { titleDecorator } from 'utils/lib';
5
5
  import calcVar from './calc-var';
6
6
  import logement from './logement';
7
+ import logementQueen from './logement-queen';
7
8
  import logementS2 from './logement-s2';
8
9
  import logementSequence from './logement-sequence';
9
- import dataLogement from './data-logement.json';
10
+ import dataLogement from './data-logement';
10
11
  import simpsons from './simpsons';
11
12
  import arithmetic from './arithmetic';
13
+ import updateExternalQuestionnaire from './update-external/questionnaire';
14
+ import updateExternalData from './update-external/data';
12
15
  import { positioningOptions, featuresOptions } from '../utils/options';
13
16
  import { boolean, select } from '@storybook/addon-knobs/react';
14
17
 
@@ -32,18 +35,20 @@ def.addWithJSX('Calculated Variables', () => (
32
35
  />
33
36
  ));
34
37
 
35
- def.addWithJSX('Logement', () => (
36
- <Orchestrator
37
- id="props"
38
- source={logement}
39
- missing={boolean('Missing', false)}
40
- features={select('Features', featuresOptions, ['VTL', 'MD'])}
41
- positioning={select('Items positioning', positioningOptions, 'DEFAULT')}
42
- disabled={boolean('Disabled', false)}
43
- focused={boolean('Focused', false)}
44
- management={boolean('Management', false)}
45
- />
46
- ));
38
+ def.addWithJSX('Logement', function () {
39
+ return (
40
+ <Orchestrator
41
+ id="props"
42
+ source={logement}
43
+ missing={boolean('Missing', false)}
44
+ features={select('Features', featuresOptions, ['VTL', 'MD'])}
45
+ positioning={select('Items positioning', positioningOptions, 'DEFAULT')}
46
+ disabled={boolean('Disabled', false)}
47
+ focused={boolean('Focused', false)}
48
+ management={boolean('Management', false)}
49
+ />
50
+ );
51
+ });
47
52
 
48
53
  def.addWithJSX('Arithmetic', () => (
49
54
  <Orchestrator
@@ -89,21 +94,42 @@ paginated.addWithJSX('Calculated Variables', () => (
89
94
  />
90
95
  ));
91
96
 
92
- paginated.addWithJSX('Logement', () => (
93
- <Orchestrator
94
- id="props"
95
- source={logement}
96
- data={dataLogement}
97
- missing={boolean('Missing', false)}
98
- activeGoNextForMissing={boolean('Active go next for missing', false)}
99
- features={select('Features', featuresOptions, ['VTL', 'MD'])}
100
- positioning={select('Items positioning', positioningOptions, 'DEFAULT')}
101
- disabled={boolean('Disabled', false)}
102
- focused={boolean('Focused', false)}
103
- management={boolean('Management', false)}
104
- pagination
105
- />
106
- ));
97
+ paginated.addWithJSX('Logement', function () {
98
+ return (
99
+ <Orchestrator
100
+ id="props"
101
+ source={logement}
102
+ data={dataLogement}
103
+ missing={boolean('Missing', false)}
104
+ activeGoNextForMissing={boolean('Active go next for missing', false)}
105
+ features={select('Features', featuresOptions, ['VTL', 'MD'])}
106
+ positioning={select('Items positioning', positioningOptions, 'DEFAULT')}
107
+ disabled={boolean('Disabled', false)}
108
+ focused={boolean('Focused', false)}
109
+ management={boolean('Management', false)}
110
+ pagination
111
+ modalForControls
112
+ />
113
+ );
114
+ });
115
+
116
+ paginated.addWithJSX('Logement - Queen', function () {
117
+ return (
118
+ <Orchestrator
119
+ id="props"
120
+ source={logementQueen}
121
+ data={dataLogement}
122
+ missing={boolean('Missing', false)}
123
+ activeGoNextForMissing={boolean('Active go next for missing', false)}
124
+ features={select('Features', featuresOptions, ['VTL', 'MD'])}
125
+ positioning={select('Items positioning', positioningOptions, 'DEFAULT')}
126
+ disabled={boolean('Disabled', false)}
127
+ focused={boolean('Focused', false)}
128
+ management={boolean('Management', false)}
129
+ pagination
130
+ />
131
+ );
132
+ });
107
133
 
108
134
  paginated.addWithJSX('Logement - Sequence', () => (
109
135
  <Orchestrator
@@ -152,3 +178,34 @@ paginated.addWithJSX('Simpsons', () => (
152
178
  pagination
153
179
  />
154
180
  ));
181
+
182
+ const other = storiesOf('Questionnaire/Other', module).addDecorator(
183
+ (Component) => {
184
+ const WrappedComponent = titleDecorator(Component);
185
+ return <WrappedComponent title="<Questionnaire />" />;
186
+ }
187
+ );
188
+
189
+ other.addWithJSX('Update external', () => {
190
+ const [addExternal, setAddExternal] = useState(null);
191
+ return (
192
+ <>
193
+ <button
194
+ onClick={() => setAddExternal({ PROMO: true })}
195
+ >{`Fire PROMO --> True`}</button>
196
+ <button
197
+ onClick={() => setAddExternal({ PROMO: false })}
198
+ >{`Fire PROMO --> False`}</button>
199
+ <Orchestrator
200
+ id="props"
201
+ source={updateExternalQuestionnaire}
202
+ data={updateExternalData}
203
+ features={select('Features', featuresOptions, ['VTL', 'MD'])}
204
+ positioning={select('Items positioning', positioningOptions, 'DEFAULT')}
205
+ disabled={boolean('Disabled', false)}
206
+ focused={boolean('Focused', false)}
207
+ addExternal={addExternal}
208
+ />
209
+ </>
210
+ );
211
+ });
@@ -0,0 +1 @@
1
+ { "EXTERNAL": { "PROMO": null } }
@@ -0,0 +1,75 @@
1
+ {
2
+ "components": [
3
+ {
4
+ "id": "seq1",
5
+ "componentType": "Sequence",
6
+ "label": "\"I - Collect number\"",
7
+ "conditionFilter": { "value": "true" }
8
+ },
9
+ {
10
+ "id": "input1",
11
+ "componentType": "InputNumber",
12
+ "label": "Number",
13
+ "conditionFilter": { "value": "true" },
14
+ "response": { "name": "NUM" },
15
+ "bindingDependencies": ["NUM"]
16
+ },
17
+ {
18
+ "id": "seq2",
19
+ "componentType": "Sequence",
20
+ "label": "\"II - Promo rate\"",
21
+ "conditionFilter": {
22
+ "value": "PROMO = true",
23
+ "bindingDependencies": ["PROMO"]
24
+ },
25
+ "bindingDependencies": ["PROMO"]
26
+ },
27
+ {
28
+ "id": "input2",
29
+ "componentType": "InputNumber",
30
+ "label": "Rate",
31
+ "conditionFilter": {
32
+ "value": "PROMO = true",
33
+ "bindingDependencies": ["PROMO"]
34
+ },
35
+ "response": {
36
+ "name": "PROMO_RATE",
37
+ "bindingDependencies": ["PROMO_RATE"]
38
+ },
39
+ "bindingDependencies": ["PROMO", "PROMO_RATE"]
40
+ }
41
+ ],
42
+ "variables": [
43
+ {
44
+ "variableType": "COLLECTED",
45
+ "name": "NUM",
46
+ "componentRef": "input1",
47
+ "values": {
48
+ "PREVIOUS": null,
49
+ "COLLECTED": null,
50
+ "FORCED": null,
51
+ "EDITED": null,
52
+ "INPUTED": null
53
+ }
54
+ },
55
+ {
56
+ "variableType": "COLLECTED",
57
+ "name": "PROMO_RATE",
58
+ "componentRef": "input2",
59
+ "values": {
60
+ "PREVIOUS": null,
61
+ "COLLECTED": null,
62
+ "FORCED": null,
63
+ "EDITED": null,
64
+ "INPUTED": null
65
+ }
66
+ },
67
+ { "variableType": "EXTERNAL", "name": "PROMO", "value": null },
68
+ {
69
+ "variableType": "CALCULATED",
70
+ "name": "DOUBLE_PROMO_RATE",
71
+ "expression": "cast(PROMO_RATE, integer) * 2",
72
+ "bindingDependencies": ["PROMO_RATE"]
73
+ }
74
+ ]
75
+ }
@@ -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';
@@ -55,6 +55,7 @@
55
55
  "max": 4,
56
56
  "decimals": 0,
57
57
  "label": "Number of inhabitants",
58
+ "conditionFilter": { "value": "true" },
58
59
  "response": {
59
60
  "name": "NUM"
60
61
  },
@@ -46,7 +46,10 @@
46
46
  "name": "libelle2",
47
47
  "rules": ["[\\w]+"],
48
48
  "language": "French",
49
- "synonyms": { "st": ["saint"] },
49
+ "synonyms": [
50
+ { "source": "saint", "target": ["st"] },
51
+ { "source": "oph", "target": ["renaud", "nicolas"] }
52
+ ],
50
53
  "stemmer": false
51
54
  },
52
55
  { "name": "code" }
@@ -58,7 +61,26 @@
58
61
  "stopWords": ["de", "la", "les", "du", "et", "au", "aux", "en"],
59
62
  "max": 12,
60
63
  "version": "1"
61
- }
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
+ }
62
84
  ],
63
85
  "components": [
64
86
  {
@@ -93,6 +115,17 @@
93
115
  "response": {
94
116
  "name": "BAILLEURS"
95
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
+ }
96
129
  }
97
130
  ],
98
131
  "variables": [
@@ -0,0 +1,27 @@
1
+ .lunatic-suggester-mui {
2
+ position: relative;
3
+ height: 37px;
4
+ margin-bottom: 18px;
5
+
6
+ .lunatic-suggester-mui-content {
7
+ position: absolute;
8
+ top: 0;
9
+ left: 0;
10
+
11
+ .lunatic-suggester-mui-selection {
12
+ z-index: 0;
13
+ }
14
+
15
+ .lunatic-suggester-mui-panel {
16
+ background-color: snow;
17
+ opacity: 1;
18
+ z-index: 10;
19
+
20
+ .lunatic-suggester-mui-option {
21
+ &.selected {
22
+ background-color: yellow;
23
+ }
24
+ }
25
+ }
26
+ }
27
+ }
@@ -0,0 +1,148 @@
1
+ import React, { useCallback, useEffect, useState, useRef } from 'react';
2
+ import classnames from 'classnames';
3
+ import TextField from '@mui/material/TextField';
4
+ import IconButton from '@mui/material/IconButton';
5
+ import ClickAwayListener from '@mui/material/ClickAwayListener';
6
+ import Stack from '@mui/material/Stack';
7
+ import Paper from '@mui/material/Paper';
8
+ import MenuList from '@mui/material/MenuList';
9
+ import MenuItem from '@mui/material/MenuItem';
10
+ import Typography from '@mui/material/Typography';
11
+ import useDocumentAddEventListener from '../../utils/to-expose/hooks/use-document-add-event-listener';
12
+ import './lunatic-suggester-mui.scss';
13
+
14
+ function SuggesterContainer({
15
+ children,
16
+ onBlur,
17
+ onFocus,
18
+ onKeyDown,
19
+ labelledBy,
20
+ }) {
21
+ const handleClickAway = useCallback(
22
+ function (e) {
23
+ onBlur();
24
+ },
25
+ [onBlur]
26
+ );
27
+
28
+ return (
29
+ <ClickAwayListener onClickAway={handleClickAway}>
30
+ <>{children}</>
31
+ </ClickAwayListener>
32
+ );
33
+ // const ref = useRef();
34
+
35
+ // const onClick = useCallback(
36
+ // function (e) {
37
+ // const { current } = ref;
38
+ // if (!current.contains(e.target)) {
39
+ // onBlur();
40
+ // }
41
+ // },
42
+ // [ref, onBlur]
43
+ // );
44
+
45
+ // useDocumentAddEventListener('mousedown', onClick);
46
+
47
+ // return (
48
+ // <div
49
+ // className="lunatic-suggester-mui"
50
+ // ref={ref}
51
+ // onFocus={onFocus}
52
+ // onBlur={onBlur}
53
+ // onKeyDown={onKeyDown}
54
+ // >
55
+ // <div className="lunatic-suggester-mui-content">{children}</div>
56
+ // </div>
57
+ // );
58
+ }
59
+
60
+ function Selection({ search, onChange }) {
61
+ return (
62
+ <TextField
63
+ value={search}
64
+ onChange={onChange}
65
+ className="lunatic-suggester-mui-selection"
66
+ />
67
+ );
68
+ }
69
+
70
+ function OptionMUI({ label, id, selected }) {
71
+ return (
72
+ <MenuItem
73
+ className={classnames('lunatic-suggester-mui-option', { selected })}
74
+ >
75
+ <Stack direction="row" spacing={1} alignItems="center">
76
+ <Typography>{id}</Typography>
77
+ <Typography>{label}</Typography>
78
+ </Stack>
79
+ </MenuItem>
80
+ );
81
+ }
82
+
83
+ function Panel({ options, expended, selectedIndex }) {
84
+ console.log({ options, expended });
85
+ if (Array.isArray(options) && options.length && expended) {
86
+ const items = options.map(function (option, index) {
87
+ const { label, id } = option;
88
+ const selected = index === selectedIndex;
89
+ return <OptionMUI key={id} id={id} label={label} selected={selected} />;
90
+ });
91
+ return (
92
+ <Paper>
93
+ <MenuList className="lunatic-suggester-mui-panel">{items}</MenuList>
94
+ </Paper>
95
+ );
96
+ }
97
+ return null;
98
+ }
99
+
100
+ function SuggesterMaterialUI({
101
+ className,
102
+ placeholderList,
103
+ labelledBy,
104
+ optionRenderer,
105
+ labelRenderer,
106
+ onSelect,
107
+ onBlur,
108
+ onDelete,
109
+ onKeyDown,
110
+ onChange,
111
+ onClickOption,
112
+ value,
113
+ onFocus,
114
+ disabled,
115
+ id,
116
+ messageError,
117
+ search,
118
+ focused,
119
+ options,
120
+ expended,
121
+ selectedIndex,
122
+ displayLabel,
123
+ }) {
124
+ const onChangeEx = useCallback(
125
+ function (e) {
126
+ onChange(e.target.value);
127
+ },
128
+ [onChange]
129
+ );
130
+
131
+ return (
132
+ <SuggesterContainer
133
+ onBlur={onBlur}
134
+ onFocus={onFocus}
135
+ onKeyDown={onKeyDown}
136
+ labelledBy={labelledBy}
137
+ >
138
+ <Selection search={search} onChange={onChangeEx} />
139
+ <Panel
140
+ options={options}
141
+ expended={expended}
142
+ selectedIndex={selectedIndex}
143
+ />
144
+ </SuggesterContainer>
145
+ );
146
+ }
147
+
148
+ export default SuggesterMaterialUI;
@@ -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();
@@ -53,7 +57,10 @@ const bailleursSociaux = {
53
57
  rules: ['[\\w]+'],
54
58
  language: 'French',
55
59
  stemmer: false,
56
- synonyms: { saint: ['st'], sainte: ['ste'] },
60
+ synonyms: [
61
+ { source: 'saint', target: ['st'] },
62
+ { source: 'oph', target: ['renaud', 'nicolas'] },
63
+ ],
57
64
  },
58
65
  { name: 'code' },
59
66
  ],
@@ -83,6 +90,27 @@ const infoNaf = {
83
90
  version: '1',
84
91
  };
85
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
+
86
114
  async function loadCog() {
87
115
  const { name } = infoCog;
88
116
  const communes = await fetchCog();
@@ -103,6 +131,16 @@ async function loadBailleurs() {
103
131
  await insertEntity(db, CONSTANTES.STORE_INFO_NAME, bailleursSociaux);
104
132
  }
105
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
+
106
144
  async function loadNaf() {
107
145
  const { name } = infoNaf;
108
146
  const rubriques = await fetchNaf();
@@ -173,6 +211,15 @@ stories.addWithJSX('Default', () => {
173
211
  />
174
212
  <Search storeInfo={bailleursSociaux} defaultValue="123" />
175
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>
176
223
  </ul>
177
224
  </>
178
225
  );
@@ -13,7 +13,8 @@ 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
-
16
+ import * as BAILLEURS2021 from './bailleurs-sociaux-2021';
17
+ import SuggesterMaterialUI from './suggester-material-ui';
17
18
  /**
18
19
  *
19
20
  */
@@ -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 {};
@@ -131,3 +136,24 @@ storiesAuto.addWithJSX('Default', () => (
131
136
  pagination
132
137
  />
133
138
  ));
139
+
140
+ stories.addWithJSX('Custom suggester', function () {
141
+ const { components } = data;
142
+ const customized = components.map(function (component) {
143
+ const { componentType } = component;
144
+ if (componentType === 'Suggester') {
145
+ return { ...component, custom: SuggesterMaterialUI };
146
+ }
147
+ return component;
148
+ });
149
+
150
+ return (
151
+ <Orchestrator
152
+ id="default"
153
+ source={{ ...data, components: customized }}
154
+ suggesterFetcher={suggesterFetcher}
155
+ autoSuggesterLoading
156
+ pagination
157
+ />
158
+ );
159
+ });
@@ -0,0 +1,31 @@
1
+ # CheckboxOne component
2
+
3
+ ## Props
4
+
5
+ | Props | Type | Default value | Required | Description |
6
+ | :-------------: | :----: | :--------------------------------------: | :------: | --------------------------------------- |
7
+ | id | string | - | ✓ | Id of the checkbox |
8
+ | label | string | "" | | Fieldset label of the checkbox |
9
+ | preferences \* | array | ["COLLECTED"] | | Preferences to manage checkbox response |
10
+ | response \* | object | {} | | Response concerned by the component |
11
+ | options \* | array | - | ✓ | Options of the checkbox |
12
+ | handleChange | func | - | ✓ | Handler of the checkbox |
13
+ | disabled | bool | false | | Is the checkbox options disabled |
14
+ | focused | bool | false | | Is the checkbox options focused |
15
+ | positioning \* | string | "DEFAULT" | | Checkbox options positioning |
16
+ | declarations \* | array | [] | | Declarations of the checkbox |
17
+ | features | array | [ ] | | Component features for labels |
18
+ | bindings | object | [ ] | | Questionnaire bindings |
19
+ | management | bool | false | | Management mode of the checkbox |
20
+ | style \* | object | { fieldsetStyle: {}, modalityStyle: {} } | | Style of the checkbox |
21
+
22
+ - `preferences` props has to be an ordered array of `COLLECTED`, `FORCED` or `EDITED`
23
+ - `response` props has to be a shape of `{name: string, values: object}`
24
+ - `options` props has to be an array made by objects with a shape of `{label: string, value: string}`
25
+ - `positioning` props has to be one of `DEFAULT`, `HORIZONTAL` or `VERTICAL`
26
+ - `declarations` are documented in the `Declarations` component
27
+ - `style` props has to be composed of `fieldsetStyle` and `modalityStyle`
28
+
29
+ ## Styles
30
+
31
+ **CheckboxOne** component has for classes `checkbox-group-list`, `checkbox-modality` and `checkbox-lunatic`.
@@ -0,0 +1,35 @@
1
+ import React, { useCallback } from 'react';
2
+ import Switch from '@mui/material/Switch';
3
+ import Stack from '@mui/material/Stack';
4
+ import Typography from '@mui/material/Typography';
5
+
6
+ function SwitchMaterialUI({
7
+ checked,
8
+ disabled,
9
+ handleChange,
10
+ statusLabel,
11
+ labelId,
12
+ }) {
13
+ const onClick = useCallback(
14
+ function () {
15
+ handleChange(!checked);
16
+ },
17
+ [checked, handleChange]
18
+ );
19
+
20
+ const { true: trueStatus, false: falseStatue } = statusLabel;
21
+ return (
22
+ <Stack direction="row" spacing={1} alignItems="center">
23
+ <Typography>{falseStatue}</Typography>
24
+ <Switch
25
+ checked={checked}
26
+ onClick={onClick}
27
+ disabled={disabled}
28
+ inputProps={{ 'aria-labelledby': labelId, 'aria-checked': checked }}
29
+ />
30
+ <Typography>{trueStatus}</Typography>
31
+ </Stack>
32
+ );
33
+ }
34
+
35
+ export default SwitchMaterialUI;