@inseefr/lunatic 0.2.63 → 0.3.0-prisme

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 (539) hide show
  1. package/LICENSE +21 -21
  2. package/README.md +25 -17
  3. package/lib/index.esm.js +3539 -0
  4. package/lib/index.esm.js.map +1 -0
  5. package/lib/index.js +3535 -3148
  6. package/lib/index.js.map +1 -1
  7. package/package.json +179 -122
  8. package/src/components/breadcrumb/breadcrumb.scss +22 -22
  9. package/src/components/breadcrumb/component.js +29 -29
  10. package/src/components/breadcrumb/index.js +1 -1
  11. package/src/components/button/button.scss +24 -26
  12. package/src/components/button/component.js +53 -25
  13. package/src/components/button/index.js +1 -1
  14. package/src/components/checkbox/boolean.js +172 -100
  15. package/src/components/checkbox/checkbox.scss +73 -39
  16. package/src/components/checkbox/group.js +231 -128
  17. package/src/components/checkbox/index.js +3 -3
  18. package/src/components/checkbox/one.js +11 -132
  19. package/src/components/component-wrapper/controls/component.js +70 -0
  20. package/src/components/component-wrapper/controls/controls.scss +6 -0
  21. package/src/components/component-wrapper/controls/index.js +1 -0
  22. package/src/components/component-wrapper/controls/validators/datepicker.js +44 -0
  23. package/src/components/component-wrapper/controls/validators/index.js +16 -0
  24. package/src/components/component-wrapper/controls/validators/input-number.js +23 -0
  25. package/src/components/component-wrapper/index.js +1 -0
  26. package/src/components/component-wrapper/missing/component.js +200 -0
  27. package/src/components/component-wrapper/missing/index.js +1 -0
  28. package/src/components/component-wrapper/missing/missing.scss +32 -0
  29. package/src/components/component-wrapper/wrapper.js +23 -0
  30. package/src/components/components.js +19 -13
  31. package/src/components/datepicker/component.js +26 -113
  32. package/src/components/datepicker/datepicker.scss +1 -16
  33. package/src/components/datepicker/index.js +1 -1
  34. package/src/components/declarations/component.js +46 -33
  35. package/src/components/declarations/declarations.scss +40 -34
  36. package/src/components/declarations/index.js +1 -1
  37. package/src/components/declarations/wrappers/index.js +3 -0
  38. package/src/components/declarations/wrappers/input-declarations-wrapper.js +328 -0
  39. package/src/components/declarations/wrappers/list-declarations-wrapper.js +232 -0
  40. package/src/components/declarations/wrappers/simple-declarations-wrapper.js +54 -0
  41. package/src/components/dropdown/commons/actions.js +65 -0
  42. package/src/components/dropdown/commons/children-to-option.js +9 -0
  43. package/src/components/dropdown/commons/cleaner-callbacks.js +58 -0
  44. package/src/components/dropdown/commons/components/dropdown-container.js +29 -0
  45. package/src/components/dropdown/commons/components/dropdown-field.js +46 -0
  46. package/src/components/dropdown/commons/components/dropdown.js +204 -0
  47. package/src/components/dropdown/commons/components/label.js +28 -0
  48. package/src/components/dropdown/commons/components/panel.js +78 -0
  49. package/src/components/dropdown/commons/event-callbacks/index.js +5 -0
  50. package/src/components/dropdown/commons/event-callbacks/on-keydown-callback.js +29 -0
  51. package/src/components/dropdown/commons/event-callbacks/on-mousedown-callback.js +15 -0
  52. package/src/components/dropdown/commons/reducer.js +152 -0
  53. package/src/components/dropdown/commons/tools/index.js +17 -0
  54. package/src/components/dropdown/component.js +135 -100
  55. package/src/components/dropdown/dropdown-edit/dropdown-edit.js +194 -0
  56. package/src/components/dropdown/dropdown-edit/icone.js +33 -0
  57. package/src/components/dropdown/dropdown-edit/index.js +11 -0
  58. package/src/components/dropdown/dropdown-edit/option.js +62 -0
  59. package/src/components/dropdown/dropdown-edit/prefix-tools.js +51 -0
  60. package/src/components/dropdown/dropdown-simple/dropdown.js +173 -0
  61. package/src/components/dropdown/dropdown-simple/index.js +20 -0
  62. package/src/components/dropdown/dropdown-simple/option.js +15 -0
  63. package/src/components/dropdown/dropdown.scss +178 -16
  64. package/src/components/dropdown/index.js +1 -1
  65. package/src/components/filter-description/component.js +42 -0
  66. package/src/components/filter-description/index.js +1 -0
  67. package/src/components/icon/assets/checkbox-checked.js +16 -0
  68. package/src/components/icon/assets/checkbox-unchecked.js +16 -0
  69. package/src/components/icon/assets/index.js +4 -0
  70. package/src/components/icon/assets/radio-checked.js +16 -0
  71. package/src/components/icon/assets/radio-unchecked.js +16 -0
  72. package/src/components/icon/component.js +33 -0
  73. package/src/components/icon/icon.scss +15 -0
  74. package/src/components/icon/index.js +1 -0
  75. package/src/components/index.js +5 -4
  76. package/src/components/index.scss +177 -75
  77. package/src/components/input/index.js +2 -2
  78. package/src/components/input/input-number.js +30 -170
  79. package/src/components/input/input.js +11 -118
  80. package/src/components/input/input.scss +31 -27
  81. package/src/components/loop/component.js +170 -0
  82. package/src/components/loop/index.js +1 -0
  83. package/src/components/loop/loop.scss +13 -0
  84. package/src/components/loop/wrapper.js +15 -0
  85. package/src/components/loop-constructor/block/block.scss +10 -0
  86. package/src/components/loop-constructor/block/component.js +9 -0
  87. package/src/components/loop-constructor/block/index.js +1 -0
  88. package/src/components/loop-constructor/index.js +1 -0
  89. package/src/components/loop-constructor/roster/component.js +8 -0
  90. package/src/components/loop-constructor/roster/index.js +1 -0
  91. package/src/components/loop-constructor/wrapper/body-component.js +146 -0
  92. package/src/components/loop-constructor/wrapper/build-components.js +33 -0
  93. package/src/components/loop-constructor/wrapper/component.js +190 -0
  94. package/src/components/loop-constructor/wrapper/index.js +1 -0
  95. package/src/components/modal/component.js +36 -0
  96. package/src/components/modal/index.js +1 -0
  97. package/src/components/modal/modal.scss +33 -0
  98. package/src/components/progress-bar/component.js +28 -28
  99. package/src/components/progress-bar/index.js +1 -1
  100. package/src/components/progress-bar/progress-bar.scss +54 -54
  101. package/src/components/radio/component.js +9 -136
  102. package/src/components/radio/index.js +1 -1
  103. package/src/components/radio/radio.scss +59 -24
  104. package/src/components/sequence/component.js +50 -43
  105. package/src/components/sequence/index.js +1 -1
  106. package/src/components/sequence/sequence.scss +10 -15
  107. package/src/components/subsequence/component.js +49 -43
  108. package/src/components/subsequence/index.js +1 -1
  109. package/src/components/suggester/check-store.js +68 -0
  110. package/src/components/suggester/commons-tools/binded-keys.js +11 -0
  111. package/src/components/suggester/commons-tools/index.js +1 -0
  112. package/src/components/suggester/components/create-on-keydown-callback.js +28 -0
  113. package/src/components/suggester/components/index.js +2 -0
  114. package/src/components/suggester/components/panel/default-option-renderer.js +27 -0
  115. package/src/components/suggester/components/panel/index.js +2 -0
  116. package/src/components/suggester/components/panel/option-container.js +61 -0
  117. package/src/components/suggester/components/panel/panel-container.js +21 -0
  118. package/src/components/suggester/components/panel/panel.js +47 -0
  119. package/src/components/suggester/components/selection/default-label-renderer.js +31 -0
  120. package/src/components/suggester/components/selection/delete.js +38 -0
  121. package/src/components/suggester/components/selection/index.js +1 -0
  122. package/src/components/suggester/components/selection/label.js +35 -0
  123. package/src/components/suggester/components/selection/selection.js +50 -0
  124. package/src/components/suggester/components/suggester-content.js +42 -0
  125. package/src/components/suggester/components/suggester.js +128 -0
  126. package/src/components/suggester/components/suggester.scss +101 -0
  127. package/src/components/suggester/default-style.scss +125 -0
  128. package/src/components/suggester/find-best-label/find-best-label.js +51 -0
  129. package/src/components/suggester/find-best-label/index.js +1 -0
  130. package/src/components/suggester/idb-suggester.js +73 -0
  131. package/src/components/suggester/index.js +1 -0
  132. package/src/components/suggester/lunatic-suggester.js +140 -0
  133. package/src/components/suggester/searching/create-searching.js +49 -0
  134. package/src/components/suggester/searching/index.js +1 -0
  135. package/src/components/suggester/state-management/actions.js +38 -0
  136. package/src/components/suggester/state-management/index.js +6 -0
  137. package/src/components/suggester/state-management/intial-state.js +13 -0
  138. package/src/components/suggester/state-management/reducer/index.js +1 -0
  139. package/src/components/suggester/state-management/reducer/reduce-on-blur.js +5 -0
  140. package/src/components/suggester/state-management/reducer/reduce-on-change-search.js +8 -0
  141. package/src/components/suggester/state-management/reducer/reduce-on-click-option.js +8 -0
  142. package/src/components/suggester/state-management/reducer/reduce-on-delete-search.js +11 -0
  143. package/src/components/suggester/state-management/reducer/reduce-on-error.js +8 -0
  144. package/src/components/suggester/state-management/reducer/reduce-on-focus.js +5 -0
  145. package/src/components/suggester/state-management/reducer/reduce-on-init.js +29 -0
  146. package/src/components/suggester/state-management/reducer/reduce-on-key-down.js +73 -0
  147. package/src/components/suggester/state-management/reducer/reduce-on-unexpected-error.js +7 -0
  148. package/src/components/suggester/state-management/reducer/reduce-on-update-options.js +11 -0
  149. package/src/components/suggester/state-management/reducer/reducer.js +38 -0
  150. package/src/components/suggester/state-management/suggester-context.js +4 -0
  151. package/src/components/suggester/state-management/use-dispatch.js +11 -0
  152. package/src/components/suggester/suggester-wrapper.js +127 -0
  153. package/src/components/suggester-loader-widget/index.js +1 -0
  154. package/src/components/suggester-loader-widget/loader-row.js +102 -0
  155. package/src/components/suggester-loader-widget/loader.js +67 -0
  156. package/src/components/suggester-loader-widget/progress.js +25 -0
  157. package/src/components/suggester-loader-widget/tools/action-tool.js +20 -0
  158. package/src/components/suggester-loader-widget/tools/index.js +2 -0
  159. package/src/components/suggester-loader-widget/tools/tools.js +7 -0
  160. package/src/components/suggester-loader-widget/widget-container.js +35 -0
  161. package/src/components/suggester-loader-widget/widget.js +123 -0
  162. package/src/components/suggester-loader-widget/widget.scss +176 -0
  163. package/src/components/table/index.js +1 -1
  164. package/src/components/table/table.js +173 -133
  165. package/src/components/table/table.scss +26 -23
  166. package/src/components/textarea/component.js +11 -117
  167. package/src/components/textarea/index.js +1 -1
  168. package/src/components/textarea/textarea.scss +8 -16
  169. package/src/components/tooltip/img/index.js +4 -4
  170. package/src/components/tooltip/index.js +1 -1
  171. package/src/components/tooltip/response.js +52 -42
  172. package/src/components/tooltip/tooltip.scss +30 -35
  173. package/src/constants/component-types.js +1 -0
  174. package/src/{utils/constants.js → constants/declarations.js} +14 -14
  175. package/src/constants/event-types.js +13 -0
  176. package/src/constants/index.js +5 -0
  177. package/src/constants/supported-preferences.js +10 -0
  178. package/src/constants/value-types.js +5 -0
  179. package/src/constants/variable-types.js +4 -0
  180. package/src/stories/breadcrumb/README.md +14 -14
  181. package/src/stories/breadcrumb/breadcrumb.stories.js +21 -35
  182. package/src/stories/button/README.md +14 -14
  183. package/src/stories/button/button.stories.js +27 -63
  184. package/src/stories/checkbox-boolean/README.md +27 -25
  185. package/src/stories/checkbox-boolean/checkbox-boolean.stories.js +54 -49
  186. package/src/stories/checkbox-boolean/data-forced.json +48 -0
  187. package/src/stories/checkbox-boolean/data.json +78 -0
  188. package/src/stories/checkbox-group/README.md +29 -28
  189. package/src/stories/checkbox-group/checkbox-group.stories.js +60 -122
  190. package/src/stories/checkbox-group/data-forced.json +89 -0
  191. package/src/stories/checkbox-group/data-vtl.json +102 -0
  192. package/src/stories/checkbox-group/data.json +89 -0
  193. package/src/stories/checkbox-one/README.md +31 -30
  194. package/src/stories/checkbox-one/checkbox-one.stories.js +57 -112
  195. package/src/stories/checkbox-one/data-forced.json +33 -0
  196. package/src/stories/checkbox-one/data-vtl.json +48 -0
  197. package/src/stories/checkbox-one/data.json +33 -0
  198. package/src/stories/datepicker/README.md +31 -27
  199. package/src/stories/datepicker/data-forced.json +28 -0
  200. package/src/stories/datepicker/data.json +45 -0
  201. package/src/stories/datepicker/datepicker.stories.js +60 -82
  202. package/src/stories/declarations/README.md +19 -17
  203. package/src/stories/declarations/declarations.stories.js +116 -61
  204. package/src/stories/dropdown/README.md +44 -29
  205. package/src/stories/dropdown/data-forced.json +81 -0
  206. package/src/stories/dropdown/data-naf.json +6963 -0
  207. package/src/stories/dropdown/data-props.json +111 -0
  208. package/src/stories/dropdown/data.json +98 -0
  209. package/src/stories/dropdown/dropdown.stories.js +89 -70
  210. package/src/stories/filter-description/README.md +15 -0
  211. package/src/stories/filter-description/filter-description.stories.js +53 -0
  212. package/src/stories/icons/icons.stories.js +16 -0
  213. package/src/stories/icons/lunatic-icon.scss +10 -0
  214. package/src/stories/input/README.md +33 -28
  215. package/src/stories/input/data-forced.json +41 -0
  216. package/src/stories/input/data.json +41 -0
  217. package/src/stories/input/input.stories.js +72 -88
  218. package/src/stories/input-number/README.md +37 -31
  219. package/src/stories/input-number/data-forced.json +27 -0
  220. package/src/stories/input-number/data.json +42 -0
  221. package/src/stories/input-number/input-number.stories.js +81 -95
  222. package/src/stories/loop/README.md +25 -0
  223. package/src/stories/loop/loop.stories.js +88 -0
  224. package/src/stories/loop/with-loop/data-loop-deeper.json +298 -0
  225. package/src/stories/loop/with-loop/data-loop.json +336 -0
  226. package/src/stories/loop/with-loop/index.js +2 -0
  227. package/src/stories/loop/with-roster/data-forced.json +213 -0
  228. package/src/stories/loop/with-roster/data-loop-deeper.json +298 -0
  229. package/src/stories/loop/with-roster/data-loop.json +288 -0
  230. package/src/stories/loop/with-roster/index.js +3 -0
  231. package/src/stories/loop-constructor/README.md +27 -0
  232. package/src/stories/loop-constructor/data-input-forced.json +64 -0
  233. package/src/stories/loop-constructor/data-input.json +100 -0
  234. package/src/stories/loop-constructor/data-loop-forced.json +66 -0
  235. package/src/stories/loop-constructor/data-loop-static-forced.json +66 -0
  236. package/src/stories/loop-constructor/data-loop-static.json +81 -0
  237. package/src/stories/loop-constructor/data-loop.json +81 -0
  238. package/src/stories/loop-constructor/data-roster-forced.json +68 -0
  239. package/src/stories/loop-constructor/data-roster.json +83 -0
  240. package/src/stories/loop-constructor/loop-constructor.stories.js +180 -0
  241. package/src/stories/pagination/deeper-loop.json +327 -0
  242. package/src/stories/pagination/pagination.stories.js +60 -0
  243. package/src/stories/pagination/simple-loop.json +277 -0
  244. package/src/stories/pagination/simpsons-question.json +4952 -0
  245. package/src/stories/pagination/simpsons-sequence.json +4362 -0
  246. package/src/stories/progress-bar/README.md +13 -13
  247. package/src/stories/progress-bar/progress-bar.stories.js +24 -24
  248. package/src/stories/questionnaire/arithmetic-management.json +47 -0
  249. package/src/stories/questionnaire/arithmetic.json +247 -0
  250. package/src/stories/questionnaire/calc-var.json +187 -0
  251. package/src/stories/questionnaire/data-logement.json +2691 -0
  252. package/src/stories/questionnaire/kish.json +275 -0
  253. package/src/stories/questionnaire/logement-queen.json +23390 -0
  254. package/src/stories/questionnaire/logement-s2.json +46028 -0
  255. package/src/stories/questionnaire/logement-sequence.json +26742 -0
  256. package/src/stories/questionnaire/logement.json +21073 -0
  257. package/src/stories/questionnaire/loop-and-controls.json +481 -0
  258. package/src/stories/questionnaire/questionnaire.stories.js +236 -0
  259. package/src/stories/questionnaire/simpsons.json +4816 -0
  260. package/src/stories/questionnaire/update-external/data.json +1 -0
  261. package/src/stories/questionnaire/update-external/questionnaire.json +75 -0
  262. package/src/stories/radio/README.md +31 -30
  263. package/src/stories/radio/data-forced.json +32 -0
  264. package/src/stories/radio/data-vtl.json +47 -0
  265. package/src/stories/radio/data.json +32 -0
  266. package/src/stories/radio/radio.stories.js +64 -110
  267. package/src/stories/sequence/README.md +18 -16
  268. package/src/stories/sequence/sequence.stories.js +32 -46
  269. package/src/stories/subsequence/README.md +18 -16
  270. package/src/stories/subsequence/subsequence.stories.js +32 -46
  271. package/src/stories/suggester/README.md +46 -0
  272. package/src/stories/suggester/bailleurs-sociaux/fetch-bailleurs.js +15 -0
  273. package/src/stories/suggester/bailleurs-sociaux/index.js +2 -0
  274. package/src/stories/suggester/bailleurs-sociaux/option-bailleur-renderer.js +58 -0
  275. package/src/stories/suggester/bailleurs-sociaux/preloader.svg +52 -0
  276. package/src/stories/suggester/bailleurs-sociaux/theme.scss +22 -0
  277. package/src/stories/suggester/bailleurs-sociaux-2021/fetch-bailleurs.js +12 -0
  278. package/src/stories/suggester/bailleurs-sociaux-2021/index.js +1 -0
  279. package/src/stories/suggester/cog-communes/fetch-cog.js +15 -0
  280. package/src/stories/suggester/cog-communes/index.js +2 -0
  281. package/src/stories/suggester/cog-communes/option-cog-renderer.js +15 -0
  282. package/src/stories/suggester/cog-communes/theme.scss +12 -0
  283. package/src/stories/suggester/data-auto.json +232 -0
  284. package/src/stories/suggester/data-vtl.json +82 -0
  285. package/src/stories/suggester/data.json +169 -0
  286. package/src/stories/suggester/naf-rev2/fetch-naf.js +57 -0
  287. package/src/stories/suggester/naf-rev2/index.js +2 -0
  288. package/src/stories/suggester/naf-rev2/option-naf-renderer.js +17 -0
  289. package/src/stories/suggester/naf-rev2/theme.scss +36 -0
  290. package/src/stories/suggester/suggester-workers.stories.js +226 -0
  291. package/src/stories/suggester/suggester.stories.js +138 -0
  292. package/src/stories/table/README.md +29 -23
  293. package/src/stories/table/data-default.json +19 -0
  294. package/src/stories/table/data-one-axis-one-measure.json +139 -0
  295. package/src/stories/table/data-one-axis-two-measures.json +208 -0
  296. package/src/stories/table/data-one-hierarchical-axis.json +219 -0
  297. package/src/stories/table/data-roster.json +486 -0
  298. package/src/stories/table/data-two-axis-one-measure.json +507 -0
  299. package/src/stories/table/table.stories.js +82 -1021
  300. package/src/stories/textarea/README.md +33 -29
  301. package/src/stories/textarea/data-forced.json +28 -0
  302. package/src/stories/textarea/data.json +43 -0
  303. package/src/stories/textarea/textarea.stories.js +68 -85
  304. package/src/stories/tooltip-response/README.md +14 -14
  305. package/src/stories/tooltip-response/md-link.json +31 -0
  306. package/src/stories/tooltip-response/md-tooltip.json +31 -0
  307. package/src/stories/tooltip-response/tooltip.stories.js +83 -43
  308. package/src/stories/utils/custom-lunatic.scss +23 -0
  309. package/src/stories/utils/img/arrow.png +0 -0
  310. package/src/stories/utils/img/check_box.svg +1 -0
  311. package/src/stories/utils/img/check_box_outline.svg +1 -0
  312. package/src/stories/utils/img/lunatic-logo.png +0 -0
  313. package/src/stories/utils/img/menu-down.svg +1 -0
  314. package/src/stories/utils/img/menu-up.svg +1 -0
  315. package/src/stories/utils/img/radio_button_checked.svg +1 -0
  316. package/src/stories/utils/img/radio_button_unchecked.svg +1 -0
  317. package/src/stories/utils/options.js +25 -0
  318. package/src/stories/utils/orchestrator-split.js +119 -0
  319. package/src/stories/utils/orchestrator.js +119 -0
  320. package/src/tests/components/breadcrumb.spec.js +13 -13
  321. package/src/tests/components/button.spec.js +11 -11
  322. package/src/tests/components/checkbox-boolean.spec.js +45 -22
  323. package/src/tests/components/checkbox-group.spec.js +53 -17
  324. package/src/tests/components/checkbox-one.spec.js +32 -17
  325. package/src/tests/components/datepicker.spec.js +22 -42
  326. package/src/tests/components/declarations-wrappers/input-declarations-wrapper.spec.js +67 -0
  327. package/src/tests/components/declarations-wrappers/list-declarations-wrapper.spec.js +52 -0
  328. package/src/tests/components/declarations-wrappers/simple-declarations-wrapper.spec.js +21 -0
  329. package/src/tests/components/declarations.spec.js +46 -46
  330. package/src/tests/components/input-number.spec.js +188 -85
  331. package/src/tests/components/input.spec.js +18 -38
  332. package/src/tests/components/loops/loop-static.json +66 -0
  333. package/src/tests/components/loops/loop.json +258 -0
  334. package/src/tests/components/loops/loop.spec.js +30 -0
  335. package/src/tests/components/loops/roster-for-loop.spec.js +18 -0
  336. package/src/tests/components/loops/roster-loop.json +71 -0
  337. package/src/tests/components/missing-wrapper.spec.js +32 -0
  338. package/src/tests/components/progress-bar.spec.js +15 -15
  339. package/src/tests/components/radio.spec.js +27 -21
  340. package/src/tests/components/sequence.spec.js +9 -9
  341. package/src/tests/components/subsequence.spec.js +9 -9
  342. package/src/tests/components/table.spec.js +11 -11
  343. package/src/tests/components/textarea.spec.js +18 -38
  344. package/src/tests/components/tooltip.spec.js +25 -0
  345. package/src/tests/setup/setupTests.js +4 -4
  346. package/src/tests/utils/lib/alphabet.spec.js +36 -0
  347. package/src/tests/utils/lib/array.spec.js +22 -0
  348. package/src/tests/utils/lib/checkbox/group.spec.js +72 -0
  349. package/src/tests/utils/lib/decorator/title-decorator.spec.js +12 -12
  350. package/src/tests/utils/lib/input-number.spec.js +18 -0
  351. package/src/tests/utils/lib/items-positioning.spec.js +17 -17
  352. package/src/tests/utils/lib/label-position.spec.js +22 -19
  353. package/src/tests/utils/lib/loops/bindings.spec.js +75 -0
  354. package/src/tests/utils/lib/loops/shared.spec.js +82 -0
  355. package/src/tests/utils/lib/missing/missing.spec.js +74 -0
  356. package/src/tests/utils/lib/missing/mock.js +137 -0
  357. package/src/tests/utils/lib/pagination/shared.spec.js +42 -0
  358. package/src/tests/utils/lib/responses.spec.js +64 -68
  359. package/src/tests/utils/lib/style.spec.js +26 -26
  360. package/src/tests/utils/lib/table/roster.spec.js +25 -25
  361. package/src/tests/utils/lib/tooltip/build-response.spec.js +95 -50
  362. package/src/tests/utils/lib/tooltip/content.spec.js +109 -0
  363. package/src/tests/utils/to-expose/handler/handler.spec.js +94 -0
  364. package/src/tests/utils/to-expose/handler/questionnaire.json +158 -0
  365. package/src/tests/utils/to-expose/handler/results/index.js +6 -0
  366. package/src/tests/utils/to-expose/handler/results/res-double.json +158 -0
  367. package/src/tests/utils/to-expose/handler/results/res-input-collected.json +158 -0
  368. package/src/tests/utils/to-expose/handler/results/res-input-edited.json +158 -0
  369. package/src/tests/utils/to-expose/handler/results/res-loop.json +158 -0
  370. package/src/tests/utils/to-expose/handler/results/res-matrix.json +158 -0
  371. package/src/tests/utils/to-expose/handler/results/res-responses.json +158 -0
  372. package/src/tests/utils/to-expose/init-questionnaire/data.json +12 -0
  373. package/src/tests/utils/to-expose/init-questionnaire/init-questionnaire.spec.js +19 -0
  374. package/src/tests/utils/to-expose/init-questionnaire/questionnaire.json +148 -0
  375. package/src/tests/utils/to-expose/init-questionnaire/result.json +181 -0
  376. package/src/tests/utils/to-expose/interpret/interpret.spec.js +48 -0
  377. package/src/tests/utils/to-expose/state/questionnaire.json +61 -0
  378. package/src/tests/utils/to-expose/state/results.js +78 -0
  379. package/src/tests/utils/to-expose/state/state.spec.js +59 -0
  380. package/src/utils/components/dragger/dragger.js +64 -0
  381. package/src/utils/components/dragger/dragger.scss +8 -0
  382. package/src/utils/components/dragger/index.js +1 -0
  383. package/src/utils/components/fab/fab.js +50 -0
  384. package/src/utils/components/fab/fab.scss +32 -0
  385. package/src/utils/components/fab/index.js +1 -0
  386. package/src/utils/components/field-wrapper.js +23 -0
  387. package/src/utils/components/is-network/index.js +1 -0
  388. package/src/utils/components/is-network/is-network.js +39 -0
  389. package/src/utils/components/is-network/use-online-status.js +51 -0
  390. package/src/utils/components/label-wrapper.js +45 -0
  391. package/src/utils/icons/closed.icon.js +24 -0
  392. package/src/utils/icons/cross.icon.js +24 -0
  393. package/src/utils/icons/load.icon.js +24 -0
  394. package/src/utils/icons/lunatic-icon.js +9 -0
  395. package/src/utils/icons/lunatic-icon.scss +4 -0
  396. package/src/utils/icons/network.icon.js +24 -0
  397. package/src/utils/icons/on-drag.icon.js +24 -0
  398. package/src/utils/icons/opened.icon.js +24 -0
  399. package/src/utils/idb-tools/clear-store.js +16 -0
  400. package/src/utils/idb-tools/create-db-opener.js +43 -0
  401. package/src/utils/idb-tools/create-open-db.js +25 -0
  402. package/src/utils/idb-tools/get-entity.js +15 -0
  403. package/src/utils/idb-tools/get-idb.js +12 -0
  404. package/src/utils/idb-tools/idb-bulk-insert.js +96 -0
  405. package/src/utils/idb-tools/index.js +10 -0
  406. package/src/utils/idb-tools/insert-entity.js +15 -0
  407. package/src/utils/idb-tools/open-db.js +13 -0
  408. package/src/utils/idb-tools/open-or-create-db.js +34 -0
  409. package/src/utils/lib/alphabet.js +1 -1
  410. package/src/utils/lib/array.js +7 -0
  411. package/src/utils/lib/checkbox/group.js +21 -0
  412. package/src/utils/lib/checkbox/index.js +1 -0
  413. package/src/utils/lib/controls/index.js +1 -0
  414. package/src/utils/lib/controls/utils.js +152 -0
  415. package/src/utils/lib/decorator/index.js +1 -1
  416. package/src/utils/lib/decorator/title-decorator.js +16 -18
  417. package/src/utils/lib/env.js +2 -0
  418. package/src/utils/lib/event.js +15 -0
  419. package/src/utils/lib/function.js +1 -0
  420. package/src/utils/lib/index.js +21 -9
  421. package/src/utils/lib/input-number.js +6 -0
  422. package/src/utils/lib/label-position.js +12 -12
  423. package/src/utils/lib/loops/bindings.js +66 -0
  424. package/src/utils/lib/loops/build-components.js +33 -0
  425. package/src/utils/lib/loops/index.js +3 -0
  426. package/src/utils/lib/loops/shared.js +55 -0
  427. package/src/utils/lib/memo-check.js +24 -0
  428. package/src/utils/lib/missing.js +52 -0
  429. package/src/utils/lib/options-positioning.js +9 -9
  430. package/src/utils/lib/pagination/flow.js +2 -0
  431. package/src/utils/lib/pagination/index.js +2 -0
  432. package/src/utils/lib/pagination/navigation/index.js +1 -0
  433. package/src/utils/lib/pagination/navigation/shared.js +256 -0
  434. package/src/utils/lib/prop-types/declarations.js +22 -22
  435. package/src/utils/lib/prop-types/index.js +5 -5
  436. package/src/utils/lib/prop-types/lines.js +6 -6
  437. package/src/utils/lib/prop-types/options.js +8 -8
  438. package/src/utils/lib/prop-types/response.js +6 -15
  439. package/src/utils/lib/prop-types/value-type.js +9 -9
  440. package/src/utils/lib/responses.js +11 -9
  441. package/src/utils/lib/splitting.js +142 -0
  442. package/src/utils/lib/style.js +10 -10
  443. package/src/utils/lib/table/index.js +1 -1
  444. package/src/utils/lib/table/roster.js +23 -21
  445. package/src/utils/lib/tooltip/build-response.js +41 -11
  446. package/src/utils/lib/tooltip/content.js +55 -46
  447. package/src/utils/lib/tooltip/index.js +6 -2
  448. package/src/utils/store-tools/auto-load.js +74 -0
  449. package/src/utils/store-tools/clear-store-data.js +8 -0
  450. package/src/utils/store-tools/clear-store-info.js +8 -0
  451. package/src/utils/store-tools/constantes.js +20 -0
  452. package/src/utils/store-tools/create/create.js +19 -0
  453. package/src/utils/store-tools/create/index.js +1 -0
  454. package/src/utils/store-tools/create/update-store-info.js +26 -0
  455. package/src/utils/store-tools/get-store-count.js +22 -0
  456. package/src/utils/store-tools/index.js +5 -0
  457. package/src/utils/store-tools/open-or-create-store.js +47 -0
  458. package/src/utils/store-tools/use-store-index.js +24 -0
  459. package/src/utils/suggester-workers/append-to-index/append.js +25 -0
  460. package/src/utils/suggester-workers/append-to-index/append.worker.js +16 -0
  461. package/src/utils/suggester-workers/append-to-index/create-append-task.js +45 -0
  462. package/src/utils/suggester-workers/append-to-index/index.js +2 -0
  463. package/src/utils/suggester-workers/append-to-index/prepare-entities.js +61 -0
  464. package/src/utils/suggester-workers/append-to-index/store-messages.js +21 -0
  465. package/src/utils/suggester-workers/commons-tokenizer/create-entity-tokenizer.js +56 -0
  466. package/src/utils/suggester-workers/commons-tokenizer/create-fields-tokenizer.js +56 -0
  467. package/src/utils/suggester-workers/commons-tokenizer/create-filter-stop-words.js +17 -0
  468. package/src/utils/suggester-workers/commons-tokenizer/filters/compose-filters.js +10 -0
  469. package/src/utils/suggester-workers/commons-tokenizer/filters/create-filter-stop-words.js +17 -0
  470. package/src/utils/suggester-workers/commons-tokenizer/filters/create-filter-stop-words.spec.js +14 -0
  471. package/src/utils/suggester-workers/commons-tokenizer/filters/filter-accents.js +12 -0
  472. package/src/utils/suggester-workers/commons-tokenizer/filters/filter-accents.spec.js +12 -0
  473. package/src/utils/suggester-workers/commons-tokenizer/filters/filter-double.js +12 -0
  474. package/src/utils/suggester-workers/commons-tokenizer/filters/filter-double.spec.js +20 -0
  475. package/src/utils/suggester-workers/commons-tokenizer/filters/filter-length.js +7 -0
  476. package/src/utils/suggester-workers/commons-tokenizer/filters/filter-length.spec.js +18 -0
  477. package/src/utils/suggester-workers/commons-tokenizer/filters/filter-stemmer.js +13 -0
  478. package/src/utils/suggester-workers/commons-tokenizer/filters/filter-stemmer.spec.js +12 -0
  479. package/src/utils/suggester-workers/commons-tokenizer/filters/filter-synonyms.js +36 -0
  480. package/src/utils/suggester-workers/commons-tokenizer/filters/filter-synonyms.spec.js +12 -0
  481. package/src/utils/suggester-workers/commons-tokenizer/filters/filter-to-lower.js +10 -0
  482. package/src/utils/suggester-workers/commons-tokenizer/filters/filter-to-lower.spec.js +12 -0
  483. package/src/utils/suggester-workers/commons-tokenizer/filters/index.js +2 -0
  484. package/src/utils/suggester-workers/commons-tokenizer/filters/stop-words.js +118 -0
  485. package/src/utils/suggester-workers/commons-tokenizer/get-regexp-from-pattern.js +8 -0
  486. package/src/utils/suggester-workers/commons-tokenizer/get-stemmer.js +18 -0
  487. package/src/utils/suggester-workers/commons-tokenizer/index.js +9 -0
  488. package/src/utils/suggester-workers/commons-tokenizer/prepare-string-indexation.js +13 -0
  489. package/src/utils/suggester-workers/commons-tokenizer/soft-tokenizer.js +7 -0
  490. package/src/utils/suggester-workers/create-worker.js +56 -0
  491. package/src/utils/suggester-workers/find-best-label/find-best-label.js +39 -0
  492. package/src/utils/suggester-workers/find-best-label/find-best-label.worker.js +40 -0
  493. package/src/utils/suggester-workers/find-best-label/index.js +0 -0
  494. package/src/utils/suggester-workers/find-best-label/tokenize.js +30 -0
  495. package/src/utils/suggester-workers/find-best-label/tokenize.spec.js +19 -0
  496. package/src/utils/suggester-workers/searching/compute-score.js +33 -0
  497. package/src/utils/suggester-workers/searching/get-db.js +18 -0
  498. package/src/utils/suggester-workers/searching/index.js +1 -0
  499. package/src/utils/suggester-workers/searching/order/create-alphanumeric-orderer.js +20 -0
  500. package/src/utils/suggester-workers/searching/order/index.js +19 -0
  501. package/src/utils/suggester-workers/searching/query-parser/index.js +2 -0
  502. package/src/utils/suggester-workers/searching/query-parser/query-parser-soft.js +7 -0
  503. package/src/utils/suggester-workers/searching/query-parser/query-parser-soft.spec.js +24 -0
  504. package/src/utils/suggester-workers/searching/query-parser/query-parser-tokenized.js +34 -0
  505. package/src/utils/suggester-workers/searching/resolve-query-parser.js +27 -0
  506. package/src/utils/suggester-workers/searching/search-in-index.js +17 -0
  507. package/src/utils/suggester-workers/searching/searching.js +70 -0
  508. package/src/utils/suggester-workers/searching/searching.worker.js +11 -0
  509. package/src/utils/to-expose/calculated-variables.js +113 -0
  510. package/src/utils/to-expose/handler.js +149 -104
  511. package/src/utils/to-expose/hooks/filter-components.js +121 -0
  512. package/src/utils/to-expose/hooks/index.js +2 -0
  513. package/src/utils/to-expose/hooks/lunatic-split.js +428 -0
  514. package/src/utils/to-expose/hooks/lunatic.js +284 -0
  515. package/src/utils/to-expose/hooks/use-document-add-event-listener.js +63 -0
  516. package/src/utils/to-expose/index.js +11 -3
  517. package/src/utils/to-expose/init-questionnaire.js +164 -47
  518. package/src/utils/to-expose/interpret/index.js +1 -0
  519. package/src/utils/to-expose/interpret/main.js +16 -0
  520. package/src/utils/to-expose/interpret/md.js +65 -0
  521. package/src/utils/to-expose/interpret/vtl.js +18 -0
  522. package/src/utils/to-expose/state.js +66 -75
  523. package/src/components/dropdown/shared/option.component.js +0 -77
  524. package/src/components/dropdown/shared/select-base.component.js +0 -148
  525. package/src/components/dropdown/shared/select-container.component.js +0 -59
  526. package/src/components/dropdown/shared/select-panel.component.js +0 -202
  527. package/src/components/dropdown/simple/index.js +0 -10
  528. package/src/components/dropdown/simple/prop-types.js +0 -14
  529. package/src/components/dropdown/simple/simple-select-list.component.js +0 -31
  530. package/src/components/dropdown/simple/simple-select-nested.component.js +0 -70
  531. package/src/components/dropdown/simple/simple-select.scss +0 -84
  532. package/src/components/dropdown/writable/index.js +0 -1
  533. package/src/components/dropdown/writable/writable-select.component.js +0 -98
  534. package/src/components/dropdown/writable/writable-select.scss +0 -113
  535. package/src/components/subsequence/subsequence.scss +0 -15
  536. package/src/tests/components/dropdown.spec.js +0 -20
  537. package/src/tests/utils/to-expose/handler.spec.js +0 -184
  538. package/src/tests/utils/to-expose/init-questionnaire.spec.js +0 -10
  539. package/src/tests/utils/to-expose/state.spec.js +0 -251
@@ -1,4 +1,4 @@
1
- import editedImg from './edited.png';
2
- import forcedImg from './forced.png';
3
-
4
- export { editedImg, forcedImg };
1
+ import editedImg from './edited.png';
2
+ import forcedImg from './forced.png';
3
+
4
+ export { editedImg, forcedImg };
@@ -1 +1 @@
1
- export { default as TooltipResponse } from './response';
1
+ export { default as TooltipResponse } from './response';
@@ -1,42 +1,52 @@
1
- import React, { useState, useEffect } from 'react';
2
- import PropTypes from 'prop-types';
3
- import * as U from '../../utils/lib';
4
- import * as img from './img';
5
- import './tooltip.scss';
6
-
7
- const TooltipResponse = ({ id, response }) => {
8
- const [tooltipElements, setTooltipElements] = useState(() =>
9
- U.buildTooltip(response)
10
- );
11
-
12
- useEffect(() => {
13
- setTooltipElements(U.buildTooltip(response));
14
- }, [response]);
15
-
16
- const { content, imgName } = tooltipElements;
17
-
18
- if (!content) return null;
19
- return (
20
- <div className="tooltip-lunatic">
21
- <img id={id} alt="img-tooltip" src={img[imgName].src || img[imgName]} />
22
- <span className="tooltip-text">
23
- <ul>
24
- {content.map(({ key, value }) => (
25
- <li key={`tooltip-${id}-content-${key}`}>{`${key} : ${value}`}</li>
26
- ))}
27
- </ul>
28
- </span>
29
- </div>
30
- );
31
- };
32
-
33
- TooltipResponse.defaultProps = {
34
- response: {},
35
- };
36
-
37
- TooltipResponse.propTypes = {
38
- id: PropTypes.string,
39
- response: U.responsePropTypes,
40
- };
41
-
42
- export default TooltipResponse;
1
+ import React, { useState, useEffect } from 'react';
2
+ import PropTypes from 'prop-types';
3
+ import ReactTooltip from 'react-tooltip';
4
+ import * as U from '../../utils/lib';
5
+ import * as img from './img';
6
+ import './tooltip.scss';
7
+
8
+ const TooltipResponse = ({ id, response }) => {
9
+ const [tooltipElements, setTooltipElements] = useState(() =>
10
+ U.buildTooltip(response)
11
+ );
12
+
13
+ useEffect(() => {
14
+ setTooltipElements(U.buildTooltip(response));
15
+ }, [response]);
16
+
17
+ const { content, imgName } = tooltipElements;
18
+
19
+ if (!content) return null;
20
+
21
+ const text = content
22
+ .map(({ key, value }) => `${key} : ${value}<br />`)
23
+ .join('');
24
+
25
+ return (
26
+ <div className="tooltip-lunatic">
27
+ <span
28
+ data-for={`${id}-management-tooltip`}
29
+ data-tip={text}
30
+ data-multiline
31
+ >
32
+ <img id={id} alt="img-tooltip" src={img[imgName].src || img[imgName]} />
33
+ </span>
34
+ <ReactTooltip
35
+ id={`${id}-management-tooltip`}
36
+ className="tooltip-text"
37
+ place="left"
38
+ />
39
+ </div>
40
+ );
41
+ };
42
+
43
+ TooltipResponse.defaultProps = {
44
+ response: {},
45
+ };
46
+
47
+ TooltipResponse.propTypes = {
48
+ id: PropTypes.string,
49
+ response: U.responsePropTypes,
50
+ };
51
+
52
+ export default TooltipResponse;
@@ -1,35 +1,30 @@
1
- @import 'src/components/index.scss';
2
-
3
- /* Tooltip container */
4
- .tooltip-lunatic {
5
- position: relative;
6
- display: inline-block;
7
- align-items: center;
8
- }
9
-
10
- /* Tooltip text */
11
- .tooltip-lunatic .tooltip-text {
12
- visibility: hidden;
13
- width: 20em;
14
- background-color: $main_color;
15
- color: #fff;
16
- padding: 5px 0;
17
- border-radius: 6px;
18
- text-align: left;
19
-
20
- /* Position the tooltip text */
21
- position: absolute;
22
- z-index: 1;
23
- bottom: 120%;
24
- left: -10em;
25
-
26
- /* Fade in tooltip */
27
- opacity: 0;
28
- transition: opacity 0.3s;
29
- }
30
-
31
- /* Show the tooltip text when you mouse over the tooltip container */
32
- .tooltip-lunatic:hover .tooltip-text {
33
- visibility: visible;
34
- opacity: 1;
35
- }
1
+ // Import index once for bundle
2
+ @import 'src/components/index.scss';
3
+
4
+ .lunatic-component {
5
+ /* Tooltip container */
6
+ .tooltip-lunatic {
7
+ position: relative;
8
+ display: inline-block;
9
+ align-items: center;
10
+ }
11
+
12
+ /* Tooltip text */
13
+ .tooltip-lunatic .tooltip-text {
14
+ min-width: 10em;
15
+ max-width: 20em;
16
+ background-color: var(--color-primary-dark);
17
+ color: #fff;
18
+ padding: 0.5em;
19
+ border-radius: 6px;
20
+ font-size: 1em;
21
+ &.place-left {
22
+ &::before {
23
+ border-left: 10px solid var(--color-primary-dark);
24
+ }
25
+ &::after {
26
+ content: none;
27
+ }
28
+ }
29
+ }
30
+ }
@@ -0,0 +1 @@
1
+ export const CHECKBOX_GROUP = 'CheckboxGroup';
@@ -1,14 +1,14 @@
1
- // Declaration position
2
-
3
- export const BEFORE_QUESTION_TEXT = 'BEFORE_QUESTION_TEXT';
4
- export const AFTER_QUESTION_TEXT = 'AFTER_QUESTION_TEXT';
5
- export const DETACHABLE = 'DETACHABLE';
6
-
7
- // Declaration types
8
-
9
- export const INSTRUCTION = 'INSTRUCTION';
10
- export const COMMENT = 'COMMENT';
11
- export const HELP = 'HELP';
12
- export const WARNING = 'WARNING';
13
- export const MESSAGE_FILTER = 'MESSAGE_FILTER';
14
- export const STATEMENT = 'STATEMENT';
1
+ // Declaration position
2
+
3
+ export const BEFORE_QUESTION_TEXT = 'BEFORE_QUESTION_TEXT';
4
+ export const AFTER_QUESTION_TEXT = 'AFTER_QUESTION_TEXT';
5
+ export const DETACHABLE = 'DETACHABLE';
6
+
7
+ // Declaration types
8
+
9
+ export const INSTRUCTION = 'INSTRUCTION';
10
+ export const COMMENT = 'COMMENT';
11
+ export const HELP = 'HELP';
12
+ export const WARNING = 'WARNING';
13
+ export const MESSAGE_FILTER = 'MESSAGE_FILTER';
14
+ export const STATEMENT = 'STATEMENT';
@@ -0,0 +1,13 @@
1
+ // Event types for paradata
2
+ export const EVENT_FOCUS_IN = 'focus-in';
3
+ export const EVENT_FOCUS_OUT = 'focus-out';
4
+ export const EVENT_SELECTION = 'selection';
5
+ export const EVENT_CLICK = 'click';
6
+ export const EVENT_VALUE_CHANGE = 'value-changed';
7
+
8
+ // Category of object
9
+ export const INPUT_CATEGORY = 'lunatic-input';
10
+ export const BUTTON_CATEGORY = 'lunatic-button';
11
+ export const LINK_CATEGORY = 'lunatic-link';
12
+ export const TOOLTIP_CATEGORY = 'lunatic-tooltip';
13
+ export const CALCULATED_VAR_CATEGORY = 'lunatic-calculated-var';
@@ -0,0 +1,5 @@
1
+ export * from './component-types';
2
+ export * from './declarations';
3
+ export * from './value-types';
4
+ export * from './variable-types';
5
+ export * from './event-types';
@@ -0,0 +1,10 @@
1
+ import * as C from './value-types';
2
+
3
+ // ORDERED ARRAY
4
+ export const supportedPreferences = [
5
+ C.PREVIOUS,
6
+ C.COLLECTED,
7
+ C.FORCED,
8
+ C.EDITED,
9
+ C.INPUTED,
10
+ ];
@@ -0,0 +1,5 @@
1
+ export const PREVIOUS = 'PREVIOUS';
2
+ export const COLLECTED = 'COLLECTED';
3
+ export const FORCED = 'FORCED';
4
+ export const EDITED = 'EDITED';
5
+ export const INPUTED = 'INPUTED';
@@ -0,0 +1,4 @@
1
+ export const EXTERNAL = 'EXTERNAL';
2
+ export const CALCULATED = 'CALCULATED';
3
+ // Already define in value-types
4
+ //export const COLLECTED = 'COLLECTED';
@@ -1,14 +1,14 @@
1
- # Breadcrumb component
2
-
3
- ## Props
4
-
5
- | Props | Type | Default value | Required | Description |
6
- | :---------: | :----: | :-----------: | :------: | -------------------------- |
7
- | elements \* | array | [ ] | | Elements of the breadcrumb |
8
- | style | object | { } | | Style of the breadcrumb |
9
-
10
- - `elements` props has to be an array composed of ordered strings
11
-
12
- ## Styles
13
-
14
- **Breadcrumb** component has for class `breadcrumb-lunatic`.
1
+ # Breadcrumb component
2
+
3
+ ## Props
4
+
5
+ | Props | Type | Default value | Required | Description |
6
+ | :---------: | :----: | :-----------: | :------: | -------------------------- |
7
+ | elements \* | array | [ ] | | Elements of the breadcrumb |
8
+ | style | object | { } | | Style of the breadcrumb |
9
+
10
+ - `elements` props has to be an array composed of ordered strings
11
+
12
+ ## Styles
13
+
14
+ **Breadcrumb** component has for class `breadcrumb-lunatic`.
@@ -1,35 +1,21 @@
1
- import React from 'react';
2
- import { storiesOf } from '@storybook/react';
3
- import { withReadme } from 'storybook-readme';
4
- import { Breadcrumb } from 'components';
5
- import readme from './README.md';
6
- import { titleDecorator } from 'utils/lib';
7
- import { number, color, object } from '@storybook/addon-knobs/react';
8
-
9
- const elements = ['Sequence', 'Sub-sequence', 'Question'];
10
-
11
- const stories = storiesOf('Breadcrumb', module)
12
- .addDecorator(withReadme(readme))
13
- .addDecorator(Component => {
14
- const WrappedComponent = titleDecorator(Component);
15
- return <WrappedComponent title="<Breadcrumb />" />;
16
- });
17
-
18
- stories.addWithJSX('Props', () => <Breadcrumb elements={elements} />);
19
-
20
- stories.addWithJSX('Styled', () => (
21
- <Breadcrumb
22
- id="styled"
23
- elements={elements}
24
- style={object('Generated style', {
25
- 'background-color': color('Background color', '#e80a4d'),
26
- color: color('Color', 'white'),
27
- 'border-radius': number('Border-radius', 0, {
28
- range: true,
29
- min: 0,
30
- max: 20,
31
- step: 1,
32
- }),
33
- })}
34
- />
35
- ));
1
+ import React from 'react';
2
+ import { storiesOf } from '@storybook/react';
3
+ import { Breadcrumb } from 'components';
4
+ import { withReadme } from 'storybook-readme';
5
+ import readme from './README.md';
6
+ import { titleDecorator } from 'utils/lib';
7
+
8
+ const elements = ['Sequence', 'Sub-sequence', 'Question'];
9
+
10
+ const stories = storiesOf('Breadcrumb', module)
11
+ .addDecorator(withReadme(readme))
12
+ .addDecorator((Component) => {
13
+ const WrappedComponent = titleDecorator(Component);
14
+ return <WrappedComponent title="<Breadcrumb />" />;
15
+ });
16
+
17
+ stories.addWithJSX('Default', () => (
18
+ <div className="lunatic-component">
19
+ <Breadcrumb id="default" elements={elements} />
20
+ </div>
21
+ ));
@@ -1,14 +1,14 @@
1
- # Button component
2
-
3
- ## Props
4
-
5
- | Props | Type | Default value | Required | Description |
6
- | :------: | :------: | :-----------: | :------: | ----------------------------- |
7
- | label | string | "button" | | Aria label |
8
- | value | string | - | ✓ | Label of the button |
9
- | onClick | function | - | ✓ | Callback |
10
- | disabled | boolean | false | | Boolean to disable the button |
11
-
12
- ## Styles
13
-
14
- **Button** component has for class `button-lunatic`.
1
+ # Button component
2
+
3
+ ## Props
4
+
5
+ | Props | Type | Default value | Required | Description |
6
+ | :------: | :------: | :-----------: | :------: | ----------------------------- |
7
+ | label | string | "button" | | Aria label |
8
+ | value | string | - | ✓ | Label of the button |
9
+ | onClick | function | - | ✓ | Callback |
10
+ | disabled | boolean | false | | Boolean to disable the button |
11
+
12
+ ## Styles
13
+
14
+ **Button** component has for class `button-lunatic`.
@@ -1,63 +1,27 @@
1
- import React from 'react';
2
- import { storiesOf } from '@storybook/react';
3
- import { withReadme } from 'storybook-readme';
4
- import { Button } from 'components';
5
- import readme from './README.md';
6
- import { titleDecorator } from 'utils/lib';
7
- import {
8
- text,
9
- boolean,
10
- number,
11
- color,
12
- object,
13
- } from '@storybook/addon-knobs/react';
14
-
15
- const stories = storiesOf('Button', module)
16
- .addDecorator(withReadme(readme))
17
- .addDecorator(Component => {
18
- const WrappedComponent = titleDecorator(Component);
19
- return <WrappedComponent title="<Button />" />;
20
- });
21
-
22
- stories.addWithJSX('Default', () => (
23
- <Button label="button-default" value="Click me !" onClick={console.log} />
24
- ));
25
-
26
- stories.addWithJSX('Props', () => (
27
- <Button
28
- label="disabled-button"
29
- value={text('Value', 'Click me !')}
30
- onClick={console.log}
31
- disabled={boolean('Disabled', false)}
32
- />
33
- ));
34
-
35
- stories.addWithJSX('Styled', () => (
36
- <Button
37
- label="styled-button"
38
- value="Click me !"
39
- onClick={console.log}
40
- style={object('Generated style', {
41
- 'border-width': number('Border-width', 5, {
42
- range: true,
43
- min: 0,
44
- max: 20,
45
- step: 1,
46
- }),
47
- 'border-radius': number('Border-radius', 10, {
48
- range: true,
49
- min: 0,
50
- max: 20,
51
- step: 1,
52
- }),
53
- color: color('Color', 'white'),
54
- 'background-color': color('Background color', '#e80a4d'),
55
- 'border-color': color('Border color', '#e80a4d'),
56
- ':hover': {
57
- color: color('Hover : color', '#e80a4d'),
58
- 'background-color': color('Hover : background color', 'white'),
59
- 'border-color': color('Hover : border color', '#e80a4d'),
60
- },
61
- })}
62
- />
63
- ));
1
+ import React from 'react';
2
+ import { storiesOf } from '@storybook/react';
3
+ import { withReadme } from 'storybook-readme';
4
+ import { Button } from 'components';
5
+ import readme from './README.md';
6
+ import { titleDecorator } from 'utils/lib';
7
+ import { text, boolean } from '@storybook/addon-knobs/react';
8
+
9
+ const stories = storiesOf('Button', module)
10
+ .addDecorator(withReadme(readme))
11
+ .addDecorator((Component) => {
12
+ const WrappedComponent = titleDecorator(Component);
13
+ return <WrappedComponent title="<Button />" />;
14
+ });
15
+
16
+ stories.addWithJSX('Default', () => (
17
+ <Button label="button-default" value="Click me !" onClick={console.log} />
18
+ ));
19
+
20
+ stories.addWithJSX('Props', () => (
21
+ <Button
22
+ label="disabled-button"
23
+ value={text('Value', 'Click me !')}
24
+ onClick={console.log}
25
+ disabled={boolean('Disabled', false)}
26
+ />
27
+ ));
@@ -1,25 +1,27 @@
1
- # CheckboxBoolean 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
- | handleChange | func | - | ✓ | Handler of the checkbox |
12
- | disabled | bool | false | | Is the checkbox item disabled |
13
- | positioning \* | string | "DEFAULT" | | Checkbox item positioning |
14
- | focused | bool | false | | Is the checkbox item focused |
15
- | declarations \* | array | [] | | Declarations of the checkbox |
16
- | tooltip | bool | false | | Tooltip of the checkbox |
17
- | style | object | {} | | Style of the checkbox |
18
-
19
- - `preferences` props has to be an ordered array of `COLLECTED`, `FORCED` or `EDITED`
20
- - `response` props has to be a shape of `{name: string, valueState: object}`
21
- - `declarations` are documented in the `Declarations` component
22
-
23
- ## Styles
24
-
25
- **CheckboxBoolean** component has for classes `checkbox-lunatic`, `checkbox-lunatic-no-margin` and `checkbox-modality`.
1
+ # CheckboxBoolean 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
+ | handleChange | func | - | ✓ | Handler of the checkbox |
12
+ | disabled | bool | false | | Is the checkbox item disabled |
13
+ | positioning \* | string | "DEFAULT" | | Checkbox item positioning |
14
+ | focused | bool | false | | Is the checkbox item focused |
15
+ | declarations \* | array | [ ] | | Declarations of the checkbox |
16
+ | features | array | [ ] | | Component features for labels |
17
+ | bindings | object | [ ] | | Questionnaire bindings |
18
+ | management | bool | false | | Management mode of the checkbox |
19
+ | style | object | { } | | Style of the checkbox |
20
+
21
+ - `preferences` props has to be an ordered array of `COLLECTED`, `FORCED` or `EDITED`
22
+ - `response` props has to be a shape of `{name: string, values: object}`
23
+ - `declarations` are documented in the `Declarations` component
24
+
25
+ ## Styles
26
+
27
+ **CheckboxBoolean** component has for classes `checkbox-lunatic` and `checkbox-boolean-modality`.
@@ -1,49 +1,54 @@
1
- import React from 'react';
2
- import { storiesOf } from '@storybook/react';
3
- import { withReadme } from 'storybook-readme';
4
- import { CheckboxBoolean } from 'components';
5
- import readme from './README.md';
6
- import { titleDecorator } from 'utils/lib';
7
- import { text, boolean, select } from '@storybook/addon-knobs/react';
8
-
9
- const positioningOptions = {
10
- DEFAULT: 'Default',
11
- HORIZONTAL: 'Horizontal',
12
- VERTICAL: 'Vertical',
13
- };
14
-
15
- const defaultProps = {
16
- handleChange: console.log,
17
- response: {
18
- name: 'CHECKBOX_BOOLEAN',
19
- valueState: [
20
- { valueType: 'COLLECTED', value: false },
21
- { valueType: 'FORCED', value: true },
22
- { valueType: 'EDITED', value: null },
23
- ],
24
- },
25
- };
26
-
27
- const stories = storiesOf('CheckboxBoolean', module)
28
- .addDecorator(withReadme(readme))
29
- .addDecorator(Component => {
30
- const WrappedComponent = titleDecorator(Component);
31
- return <WrappedComponent title="<CheckboxBoolean />" />;
32
- });
33
-
34
- stories.addWithJSX('Default', () => (
35
- <CheckboxBoolean id="default" {...defaultProps} />
36
- ));
37
-
38
- stories.addWithJSX('Props', () => (
39
- <CheckboxBoolean
40
- id="props"
41
- label={text('Label', "I'm the label of the boolean checkbox")}
42
- positioning={select('Items positioning', positioningOptions)}
43
- disabled={boolean('Disabled', false)}
44
- focused={boolean('Focused', false)}
45
- preferences={['COLLECTED', 'FORCED', 'EDITED']}
46
- tooltip={boolean('Tooltip', false)}
47
- {...defaultProps}
48
- />
49
- ));
1
+ import React, { useState } from 'react';
2
+ import { storiesOf } from '@storybook/react';
3
+ import { withReadme } from 'storybook-readme';
4
+ import Orchestrator from '../utils/orchestrator';
5
+ import readme from './README.md';
6
+ import { titleDecorator } from 'utils/lib';
7
+ import data from './data';
8
+ import dataForced from './data-forced';
9
+ import { boolean, select, object } from '@storybook/addon-knobs/react';
10
+ import { positioningOptions, featuresOptions } from '../utils/options';
11
+
12
+ const stories = storiesOf('CheckboxBoolean', module)
13
+ .addDecorator(withReadme(readme))
14
+ .addDecorator((Component) => {
15
+ const WrappedComponent = titleDecorator(Component);
16
+ return <WrappedComponent title="<CheckboxBoolean />" />;
17
+ });
18
+
19
+ stories.addWithJSX('Default', () => <Orchestrator source={data} />);
20
+
21
+ stories.addWithJSX('Props', () => (
22
+ <Orchestrator
23
+ source={data}
24
+ positioning={select('Items positioning', positioningOptions, 'DEFAULT')}
25
+ features={select('Features', featuresOptions, ['VTL', 'MD'])}
26
+ missing={boolean('Missing', false)}
27
+ bindings={object('Bindings', { test: 'test' })}
28
+ disabled={boolean('Disabled', false)}
29
+ focused={boolean('Focused', false)}
30
+ management={boolean('Management', false)}
31
+ />
32
+ ));
33
+
34
+ stories.addWithJSX('External update', () => {
35
+ const Fake = () => {
36
+ const [up, setUp] = useState(false);
37
+ return (
38
+ <>
39
+ <button
40
+ type="button"
41
+ onClick={() => {
42
+ setUp(true);
43
+ }}
44
+ disabled={up}
45
+ >
46
+ Force external update
47
+ </button>
48
+
49
+ <Orchestrator id="default" source={up ? dataForced : data} />
50
+ </>
51
+ );
52
+ };
53
+ return <Fake />;
54
+ });