@inseefr/lunatic 3.5.0-rc.0 → 3.5.0-rc.1

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 (392) hide show
  1. package/components/Datepicker/Datepicker.js +1 -1
  2. package/components/Datepicker/Datepicker.js.map +1 -1
  3. package/components/Duration/Duration.js +3 -2
  4. package/components/Duration/Duration.js.map +1 -1
  5. package/components/Input/Input.js +6 -3
  6. package/components/Input/Input.js.map +1 -1
  7. package/components/Input/Input.spec.js +25 -0
  8. package/components/Input/Input.spec.js.map +1 -1
  9. package/components/InputNumber/InputNumber.js +1 -1
  10. package/components/InputNumber/InputNumber.js.map +1 -1
  11. package/components/InputNumber/InputNumber.spec.js +9 -1
  12. package/components/InputNumber/InputNumber.spec.js.map +1 -1
  13. package/components/InputNumber/InputNumberThousand.d.ts +2 -1
  14. package/components/InputNumber/InputNumberThousand.js +8 -2
  15. package/components/InputNumber/InputNumberThousand.js.map +1 -1
  16. package/components/Loop/Loop.js +1 -1
  17. package/components/Loop/Loop.js.map +1 -1
  18. package/components/Loop/Loop.spec.d.ts +1 -0
  19. package/components/Loop/Loop.spec.js +39 -0
  20. package/components/Loop/Loop.spec.js.map +1 -0
  21. package/components/Roundabout/CustomRoundabout.d.ts +1 -1
  22. package/components/Roundabout/CustomRoundabout.js +4 -3
  23. package/components/Roundabout/CustomRoundabout.js.map +1 -1
  24. package/components/Roundabout/roundabout.spec.js +3 -1
  25. package/components/Roundabout/roundabout.spec.js.map +1 -1
  26. package/components/Textarea/Textarea.js +4 -1
  27. package/components/Textarea/Textarea.js.map +1 -1
  28. package/components/Textarea/Textarea.spec.js +13 -0
  29. package/components/Textarea/Textarea.spec.js.map +1 -1
  30. package/components/shared/CharactersCount/CharactersCount.d.ts +7 -0
  31. package/components/shared/CharactersCount/CharactersCount.js +20 -0
  32. package/components/shared/CharactersCount/CharactersCount.js.map +1 -0
  33. package/components/shared/CharactersCount/CharactersCount.spec.d.ts +1 -0
  34. package/components/shared/CharactersCount/CharactersCount.spec.js +28 -0
  35. package/components/shared/CharactersCount/CharactersCount.spec.js.map +1 -0
  36. package/components/shared/Label/Label.js +1 -1
  37. package/components/shared/Label/Label.js.map +1 -1
  38. package/components/shared/Label/Label.spec.js +11 -3
  39. package/components/shared/Label/Label.spec.js.map +1 -1
  40. package/components/shared/utils/getCharactersCountId.d.ts +4 -0
  41. package/components/shared/utils/getCharactersCountId.js +10 -0
  42. package/components/shared/utils/getCharactersCountId.js.map +1 -0
  43. package/components/type.d.ts +1 -0
  44. package/esm/components/Datepicker/Datepicker.js +1 -1
  45. package/esm/components/Datepicker/Datepicker.js.map +1 -1
  46. package/esm/components/Duration/Duration.js +3 -2
  47. package/esm/components/Duration/Duration.js.map +1 -1
  48. package/esm/components/Input/Input.js +6 -3
  49. package/esm/components/Input/Input.js.map +1 -1
  50. package/esm/components/Input/Input.spec.js +25 -0
  51. package/esm/components/Input/Input.spec.js.map +1 -1
  52. package/esm/components/InputNumber/InputNumber.js +1 -1
  53. package/esm/components/InputNumber/InputNumber.js.map +1 -1
  54. package/esm/components/InputNumber/InputNumber.spec.js +9 -1
  55. package/esm/components/InputNumber/InputNumber.spec.js.map +1 -1
  56. package/esm/components/InputNumber/InputNumberThousand.d.ts +2 -1
  57. package/esm/components/InputNumber/InputNumberThousand.js +8 -2
  58. package/esm/components/InputNumber/InputNumberThousand.js.map +1 -1
  59. package/esm/components/Loop/Loop.js +1 -1
  60. package/esm/components/Loop/Loop.js.map +1 -1
  61. package/esm/components/Loop/Loop.spec.d.ts +1 -0
  62. package/esm/components/Loop/Loop.spec.js +37 -0
  63. package/esm/components/Loop/Loop.spec.js.map +1 -0
  64. package/esm/components/Roundabout/CustomRoundabout.d.ts +1 -1
  65. package/esm/components/Roundabout/CustomRoundabout.js +4 -3
  66. package/esm/components/Roundabout/CustomRoundabout.js.map +1 -1
  67. package/esm/components/Roundabout/roundabout.spec.js +3 -1
  68. package/esm/components/Roundabout/roundabout.spec.js.map +1 -1
  69. package/esm/components/Textarea/Textarea.js +4 -1
  70. package/esm/components/Textarea/Textarea.js.map +1 -1
  71. package/esm/components/Textarea/Textarea.spec.js +13 -0
  72. package/esm/components/Textarea/Textarea.spec.js.map +1 -1
  73. package/esm/components/shared/CharactersCount/CharactersCount.d.ts +7 -0
  74. package/esm/components/shared/CharactersCount/CharactersCount.js +15 -0
  75. package/esm/components/shared/CharactersCount/CharactersCount.js.map +1 -0
  76. package/esm/components/shared/CharactersCount/CharactersCount.spec.d.ts +1 -0
  77. package/esm/components/shared/CharactersCount/CharactersCount.spec.js +26 -0
  78. package/esm/components/shared/CharactersCount/CharactersCount.spec.js.map +1 -0
  79. package/esm/components/shared/Label/Label.js +1 -1
  80. package/esm/components/shared/Label/Label.js.map +1 -1
  81. package/esm/components/shared/Label/Label.spec.js +11 -3
  82. package/esm/components/shared/Label/Label.spec.js.map +1 -1
  83. package/esm/components/shared/utils/getCharactersCountId.d.ts +4 -0
  84. package/esm/components/shared/utils/getCharactersCountId.js +7 -0
  85. package/esm/components/shared/utils/getCharactersCountId.js.map +1 -0
  86. package/esm/components/type.d.ts +1 -0
  87. package/esm/main.css +20 -0
  88. package/esm/main.css.map +1 -1
  89. package/esm/stories/overview/sourceWithHierarchy.json +5151 -0
  90. package/esm/tests/utils/lunatic.d.ts +0 -4
  91. package/esm/tests/utils/lunatic.js +0 -4
  92. package/esm/tests/utils/lunatic.js.map +1 -1
  93. package/esm/type.source.d.ts +6 -6
  94. package/esm/type.source.js +0 -1
  95. package/esm/type.source.js.map +1 -1
  96. package/esm/use-lunatic/commons/page.js +8 -0
  97. package/esm/use-lunatic/commons/page.js.map +1 -1
  98. package/esm/use-lunatic/commons/variables/behaviours/cleaning-behaviour.d.ts +1 -1
  99. package/esm/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js +111 -14
  100. package/esm/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js.map +1 -1
  101. package/esm/use-lunatic/commons/variables/get-questionnaire-data.js +0 -8
  102. package/esm/use-lunatic/commons/variables/get-questionnaire-data.js.map +1 -1
  103. package/esm/use-lunatic/commons/variables/lunatic-variables-store.d.ts +2 -2
  104. package/esm/use-lunatic/commons/variables/lunatic-variables-store.js +5 -3
  105. package/esm/use-lunatic/commons/variables/lunatic-variables-store.js.map +1 -1
  106. package/esm/use-lunatic/commons/variables/lunatic-variables-store.spec.js +164 -8
  107. package/esm/use-lunatic/commons/variables/lunatic-variables-store.spec.js.map +1 -1
  108. package/esm/use-lunatic/hooks/use-page-has-response.js +50 -35
  109. package/esm/use-lunatic/hooks/use-page-has-response.js.map +1 -1
  110. package/esm/use-lunatic/hooks/useOverview.d.ts +1 -1
  111. package/esm/use-lunatic/hooks/useOverview.js +19 -14
  112. package/esm/use-lunatic/hooks/useOverview.js.map +1 -1
  113. package/esm/use-lunatic/hooks/useOverview.spec.d.ts +1 -0
  114. package/esm/use-lunatic/hooks/useOverview.spec.js +38 -0
  115. package/esm/use-lunatic/hooks/useOverview.spec.js.map +1 -0
  116. package/esm/use-lunatic/props/getComponentTypeProps.d.ts +1 -0
  117. package/esm/use-lunatic/props/propValue.js +18 -6
  118. package/esm/use-lunatic/props/propValue.js.map +1 -1
  119. package/esm/use-lunatic/props/propValue.spec.js +97 -2
  120. package/esm/use-lunatic/props/propValue.spec.js.map +1 -1
  121. package/esm/use-lunatic/reducer/reducerInitializer.d.ts +2 -2
  122. package/esm/use-lunatic/reducer/reducerInitializer.js +25 -32
  123. package/esm/use-lunatic/reducer/reducerInitializer.js.map +1 -1
  124. package/esm/use-lunatic/test.utils.d.ts +2 -0
  125. package/esm/use-lunatic/test.utils.js +13 -0
  126. package/esm/use-lunatic/test.utils.js.map +1 -0
  127. package/esm/use-lunatic/type.d.ts +0 -4
  128. package/esm/use-lunatic/use-lunatic.d.ts +1 -2
  129. package/esm/use-lunatic/use-lunatic.js.map +1 -1
  130. package/esm/utils/cast.d.ts +19 -0
  131. package/esm/utils/cast.js +63 -0
  132. package/esm/utils/cast.js.map +1 -0
  133. package/esm/utils/constants/variable-status.d.ts +0 -4
  134. package/esm/utils/constants/variable-status.js +0 -4
  135. package/esm/utils/constants/variable-status.js.map +1 -1
  136. package/esm/utils/variables.spec.js +0 -8
  137. package/esm/utils/variables.spec.js.map +1 -1
  138. package/main.css +20 -0
  139. package/main.css.map +1 -1
  140. package/package.json +61 -69
  141. package/src/components/Datepicker/Datepicker.tsx +1 -1
  142. package/src/components/Datepicker/__snapshots__/Datepicker.spec.tsx.snap +2 -2
  143. package/src/components/Duration/Duration.test.tsx +52 -0
  144. package/src/components/Duration/Duration.tsx +17 -4
  145. package/src/components/Input/Input.spec.tsx +34 -0
  146. package/src/components/Input/Input.tsx +26 -18
  147. package/src/components/Input/__snapshots__/Input.spec.tsx.snap +38 -19
  148. package/src/components/InputNumber/InputNumber.spec.tsx +15 -1
  149. package/src/components/InputNumber/InputNumber.tsx +1 -0
  150. package/src/components/InputNumber/InputNumberThousand.tsx +11 -1
  151. package/src/components/Loop/Loop.spec.tsx +77 -0
  152. package/src/components/Loop/Loop.tsx +1 -1
  153. package/src/components/RosterForLoop/__snapshots__/RosterForLoop.spec.tsx.snap +42 -20
  154. package/src/components/Roundabout/CustomRoundabout.tsx +13 -4
  155. package/src/components/Roundabout/roundabout.spec.tsx +3 -0
  156. package/src/components/Textarea/Textarea.spec.tsx +18 -0
  157. package/src/components/Textarea/Textarea.tsx +21 -13
  158. package/src/components/Textarea/__snapshots__/Textarea.spec.tsx.snap +21 -11
  159. package/src/components/shared/CharactersCount/CharactersCount.spec.tsx +31 -0
  160. package/src/components/shared/CharactersCount/CharactersCount.tsx +27 -0
  161. package/src/components/shared/Label/Label.spec.tsx +15 -3
  162. package/src/components/shared/Label/Label.tsx +1 -1
  163. package/src/components/shared/utils/getCharactersCountId.test.ts +14 -0
  164. package/src/components/shared/utils/getCharactersCountId.ts +6 -0
  165. package/src/components/type.ts +1 -0
  166. package/src/css/components/Input.scss +10 -0
  167. package/src/css/components/Roundabout.scss +10 -0
  168. package/src/stories/accordion/source.json +1 -5
  169. package/src/stories/behaviour/cleaning/cleaning.stories.jsx +11 -0
  170. package/src/stories/behaviour/cleaning/loop.json +246 -0
  171. package/src/stories/behaviour/cleaning/source-loop.json +3 -15
  172. package/src/stories/behaviour/cleaning/source.json +2 -10
  173. package/src/stories/behaviour/controls/boucles-n.json +2 -10
  174. package/src/stories/behaviour/controls/loop.json +2 -10
  175. package/src/stories/behaviour/controls/roundabout.json +3 -15
  176. package/src/stories/behaviour/controls/simple-numeric.json +19 -95
  177. package/src/stories/behaviour/controls/simple.json +7 -35
  178. package/src/stories/behaviour/filter/dataLoop.json +0 -8
  179. package/src/stories/behaviour/filter/source.json +0 -12
  180. package/src/stories/behaviour/filter/sourceLoop.json +0 -12
  181. package/src/stories/behaviour/missing/source.json +12 -60
  182. package/src/stories/behaviour/others/V2_DeclarationsSimples.json +14 -70
  183. package/src/stories/behaviour/others/V2_MinMaxSum_Boucles.json +5 -25
  184. package/src/stories/behaviour/others/V2_QuestSimple_Boucles.json +107 -535
  185. package/src/stories/behaviour/others/V2_TCMRallyeGames.json +33 -165
  186. package/src/stories/behaviour/others/test-dylan.json +5 -25
  187. package/src/stories/behaviour/paste/source.json +1 -5
  188. package/src/stories/behaviour/performance/performance.stories.jsx +9 -1
  189. package/src/stories/behaviour/performance/source.json +4 -20
  190. package/src/stories/behaviour/performance/srcv.json +44747 -0
  191. package/src/stories/behaviour/resizing/source-resizing-cleaning.json +2 -10
  192. package/src/stories/behaviour/resizing/source.json +5 -25
  193. package/src/stories/checkbox-boolean/source.json +1 -5
  194. package/src/stories/checkbox-group/source.json +16 -80
  195. package/src/stories/checkbox-group/sourceCondition.json +3 -15
  196. package/src/stories/checkbox-group/sourceDetail.json +18 -90
  197. package/src/stories/checkbox-group/sourceLoop.json +2 -10
  198. package/src/stories/checkbox-one/source.json +1 -5
  199. package/src/stories/checkbox-one/sourceDetail.json +2 -10
  200. package/src/stories/date-picker/source.json +1 -5
  201. package/src/stories/declaration/source.json +2 -10
  202. package/src/stories/disabled/data.json +0 -16
  203. package/src/stories/disabled/source.json +7 -35
  204. package/src/stories/dropdown/data.json +2 -10
  205. package/src/stories/dropdown/source.json +2 -10
  206. package/src/stories/duration/mois.json +1 -5
  207. package/src/stories/duration/time.json +1 -5
  208. package/src/stories/filter-description/source-options.json +3 -15
  209. package/src/stories/input/source.json +1 -5
  210. package/src/stories/input-number/input-number.stories.jsx +5 -0
  211. package/src/stories/input-number/source-big-number.json +27 -0
  212. package/src/stories/input-number/source-euro.json +2 -6
  213. package/src/stories/input-number/source.json +1 -5
  214. package/src/stories/loop/source-bloc.json +2 -10
  215. package/src/stories/loop/source-paginated.json +2 -10
  216. package/src/stories/loop/source-roster.json +2 -10
  217. package/src/stories/loop/source-with-header.json +2 -10
  218. package/src/stories/overview/dataLoop.json +24 -120
  219. package/src/stories/overview/overview.stories.jsx +9 -0
  220. package/src/stories/overview/source.json +1 -5
  221. package/src/stories/overview/sourceLoop.json +24 -120
  222. package/src/stories/overview/sourceWithHierarchy.json +164 -820
  223. package/src/stories/pairwise/source.json +5 -25
  224. package/src/stories/question/source.json +2 -10
  225. package/src/stories/questionnaires/logement/data.json +0 -1288
  226. package/src/stories/questionnaires/logement/source-sequence.json +564 -2820
  227. package/src/stories/questionnaires/logement/source-sum.json +280 -1400
  228. package/src/stories/questionnaires/logement/source.json +564 -2820
  229. package/src/stories/questionnaires/recensement/source.json +106 -530
  230. package/src/stories/questionnaires/rp/source.json +8 -40
  231. package/src/stories/questionnaires/simpsons/source.json +104 -520
  232. package/src/stories/radio/source.json +1 -5
  233. package/src/stories/radio/sourceCondition.json +2 -10
  234. package/src/stories/radio/sourceDetail.json +2 -10
  235. package/src/stories/radio/sourceHorizontal.json +1 -5
  236. package/src/stories/roundabout/data1.json +0 -12
  237. package/src/stories/roundabout/data2.json +0 -16
  238. package/src/stories/roundabout/source.json +11 -35
  239. package/src/stories/suggester/source-arbitrary-response.json +6 -30
  240. package/src/stories/suggester/source-error.json +6 -30
  241. package/src/stories/suggester/source-multiline.json +0 -16
  242. package/src/stories/suggester/source-option-responses.json +5 -25
  243. package/src/stories/suggester/source.json +7 -35
  244. package/src/stories/summary/data.json +0 -16
  245. package/src/stories/summary/source.json +7 -35
  246. package/src/stories/switch/data-forced.json +2 -10
  247. package/src/stories/switch/source.json +4 -20
  248. package/src/stories/table/source-colspan.json +8 -40
  249. package/src/stories/table/table-dynamique.json +1 -5
  250. package/src/stories/text/source-roster.json +3 -15
  251. package/src/stories/text/source-table.json +9 -45
  252. package/src/stories/textarea/source.json +1 -5
  253. package/src/stories/utils/{SchemaValidator.tsx → SchemaValidator.jsx} +1 -1
  254. package/src/stories/utils/{orchestrator.tsx → orchestrator.jsx} +9 -13
  255. package/src/stories/utils/{overview.tsx → overview.jsx} +0 -2
  256. package/src/tests/utils/lunatic.ts +0 -4
  257. package/src/type.source.ts +8 -7
  258. package/src/use-lunatic/__snapshots__/use-lunatic.test.ts.snap +0 -1159
  259. package/src/use-lunatic/commons/page.ts +10 -0
  260. package/src/use-lunatic/commons/variables/behaviours/cleaning-behaviour.ts +182 -24
  261. package/src/use-lunatic/commons/variables/get-questionnaire-data.ts +0 -12
  262. package/src/use-lunatic/commons/variables/lunatic-variables-store.spec.ts +190 -8
  263. package/src/use-lunatic/commons/variables/lunatic-variables-store.ts +7 -4
  264. package/src/use-lunatic/hooks/use-page-has-response.test.ts +200 -0
  265. package/src/use-lunatic/hooks/use-page-has-response.ts +67 -44
  266. package/src/use-lunatic/hooks/useOverview.spec.ts +42 -0
  267. package/src/use-lunatic/hooks/useOverview.ts +41 -18
  268. package/src/use-lunatic/props/propValue.spec.ts +105 -2
  269. package/src/use-lunatic/props/propValue.ts +26 -8
  270. package/src/use-lunatic/reducer/reducerInitializer.tsx +31 -41
  271. package/src/use-lunatic/test.utils.ts +17 -0
  272. package/src/use-lunatic/type.ts +0 -4
  273. package/src/use-lunatic/use-lunatic.test.ts +2 -21
  274. package/src/use-lunatic/use-lunatic.ts +5 -4
  275. package/src/utils/cast.ts +67 -0
  276. package/src/utils/constants/variable-status.ts +0 -4
  277. package/src/utils/variables.spec.ts +0 -8
  278. package/stories/overview/sourceWithHierarchy.json +5151 -0
  279. package/tests/utils/lunatic.d.ts +0 -4
  280. package/tests/utils/lunatic.js +0 -4
  281. package/tests/utils/lunatic.js.map +1 -1
  282. package/tsconfig.build.tsbuildinfo +1 -1
  283. package/type.source.d.ts +6 -6
  284. package/type.source.js +0 -1
  285. package/type.source.js.map +1 -1
  286. package/use-lunatic/commons/page.js +8 -0
  287. package/use-lunatic/commons/page.js.map +1 -1
  288. package/use-lunatic/commons/variables/behaviours/cleaning-behaviour.d.ts +1 -1
  289. package/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js +111 -14
  290. package/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js.map +1 -1
  291. package/use-lunatic/commons/variables/get-questionnaire-data.js +0 -8
  292. package/use-lunatic/commons/variables/get-questionnaire-data.js.map +1 -1
  293. package/use-lunatic/commons/variables/lunatic-variables-store.d.ts +2 -2
  294. package/use-lunatic/commons/variables/lunatic-variables-store.js +5 -3
  295. package/use-lunatic/commons/variables/lunatic-variables-store.js.map +1 -1
  296. package/use-lunatic/commons/variables/lunatic-variables-store.spec.js +187 -8
  297. package/use-lunatic/commons/variables/lunatic-variables-store.spec.js.map +1 -1
  298. package/use-lunatic/hooks/use-page-has-response.js +49 -34
  299. package/use-lunatic/hooks/use-page-has-response.js.map +1 -1
  300. package/use-lunatic/hooks/useOverview.d.ts +1 -1
  301. package/use-lunatic/hooks/useOverview.js +19 -14
  302. package/use-lunatic/hooks/useOverview.js.map +1 -1
  303. package/use-lunatic/hooks/useOverview.spec.d.ts +1 -0
  304. package/use-lunatic/hooks/useOverview.spec.js +43 -0
  305. package/use-lunatic/hooks/useOverview.spec.js.map +1 -0
  306. package/use-lunatic/props/getComponentTypeProps.d.ts +1 -0
  307. package/use-lunatic/props/propValue.js +18 -6
  308. package/use-lunatic/props/propValue.js.map +1 -1
  309. package/use-lunatic/props/propValue.spec.js +97 -2
  310. package/use-lunatic/props/propValue.spec.js.map +1 -1
  311. package/use-lunatic/reducer/reducerInitializer.d.ts +2 -2
  312. package/use-lunatic/reducer/reducerInitializer.js +25 -32
  313. package/use-lunatic/reducer/reducerInitializer.js.map +1 -1
  314. package/use-lunatic/test.utils.d.ts +2 -0
  315. package/use-lunatic/test.utils.js +17 -0
  316. package/use-lunatic/test.utils.js.map +1 -0
  317. package/use-lunatic/type.d.ts +0 -4
  318. package/use-lunatic/use-lunatic.d.ts +1 -2
  319. package/use-lunatic/use-lunatic.js.map +1 -1
  320. package/utils/cast.d.ts +19 -0
  321. package/utils/cast.js +70 -0
  322. package/utils/cast.js.map +1 -0
  323. package/utils/constants/variable-status.d.ts +0 -4
  324. package/utils/constants/variable-status.js +1 -5
  325. package/utils/constants/variable-status.js.map +1 -1
  326. package/utils/variables.spec.js +0 -8
  327. package/utils/variables.spec.js.map +1 -1
  328. package/constants/component-types.d.ts +0 -1
  329. package/constants/component-types.js +0 -5
  330. package/constants/component-types.js.map +0 -1
  331. package/constants/declarations.d.ts +0 -9
  332. package/constants/declarations.js +0 -15
  333. package/constants/declarations.js.map +0 -1
  334. package/constants/event-types.d.ts +0 -10
  335. package/constants/event-types.js +0 -16
  336. package/constants/event-types.js.map +0 -1
  337. package/constants/index.d.ts +0 -5
  338. package/constants/index.js +0 -22
  339. package/constants/index.js.map +0 -1
  340. package/constants/indexedDBStore.d.ts +0 -21
  341. package/constants/indexedDBStore.js +0 -22
  342. package/constants/indexedDBStore.js.map +0 -1
  343. package/constants/supported-preferences.d.ts +0 -1
  344. package/constants/supported-preferences.js +0 -36
  345. package/constants/supported-preferences.js.map +0 -1
  346. package/constants/value-types.d.ts +0 -5
  347. package/constants/value-types.js +0 -9
  348. package/constants/value-types.js.map +0 -1
  349. package/constants/variable-types.d.ts +0 -2
  350. package/constants/variable-types.js +0 -8
  351. package/constants/variable-types.js.map +0 -1
  352. package/esm/constants/component-types.d.ts +0 -1
  353. package/esm/constants/component-types.js +0 -2
  354. package/esm/constants/component-types.js.map +0 -1
  355. package/esm/constants/declarations.d.ts +0 -9
  356. package/esm/constants/declarations.js +0 -12
  357. package/esm/constants/declarations.js.map +0 -1
  358. package/esm/constants/event-types.d.ts +0 -10
  359. package/esm/constants/event-types.js +0 -13
  360. package/esm/constants/event-types.js.map +0 -1
  361. package/esm/constants/index.d.ts +0 -5
  362. package/esm/constants/index.js +0 -6
  363. package/esm/constants/index.js.map +0 -1
  364. package/esm/constants/indexedDBStore.d.ts +0 -21
  365. package/esm/constants/indexedDBStore.js +0 -19
  366. package/esm/constants/indexedDBStore.js.map +0 -1
  367. package/esm/constants/supported-preferences.d.ts +0 -1
  368. package/esm/constants/supported-preferences.js +0 -10
  369. package/esm/constants/supported-preferences.js.map +0 -1
  370. package/esm/constants/value-types.d.ts +0 -5
  371. package/esm/constants/value-types.js +0 -6
  372. package/esm/constants/value-types.js.map +0 -1
  373. package/esm/constants/variable-types.d.ts +0 -2
  374. package/esm/constants/variable-types.js +0 -5
  375. package/esm/constants/variable-types.js.map +0 -1
  376. package/esm/hooks/useArticulation.d.ts +0 -58
  377. package/esm/hooks/useArticulation.js +0 -81
  378. package/esm/hooks/useArticulation.js.map +0 -1
  379. package/hooks/useArticulation.d.ts +0 -58
  380. package/hooks/useArticulation.js +0 -81
  381. package/hooks/useArticulation.js.map +0 -1
  382. package/src/constants/component-types.ts +0 -1
  383. package/src/constants/declarations.ts +0 -14
  384. package/src/constants/event-types.ts +0 -13
  385. package/src/constants/index.ts +0 -5
  386. package/src/constants/indexedDBStore.ts +0 -20
  387. package/src/constants/supported-preferences.ts +0 -10
  388. package/src/constants/value-types.ts +0 -5
  389. package/src/constants/variable-types.ts +0 -4
  390. package/src/hooks/useArticulation.ts +0 -124
  391. package/src/stories/behaviour/articulation/articulation.stories.tsx +0 -105
  392. package/src/stories/behaviour/articulation/roundabout.json +0 -348
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@inseefr/lunatic",
3
- "version": "3.5.0-rc.0",
3
+ "version": "3.5.0-rc.1",
4
4
  "description": "Library of questionnaire components",
5
5
  "repository": {
6
6
  "type": "git",
@@ -51,6 +51,7 @@
51
51
  "src/components/Dropdown/__snapshots__/Dropdown.spec.tsx.snap",
52
52
  "src/components/Dropdown/renderer/SimpleLabelRenderer.tsx",
53
53
  "src/components/Dropdown/renderer/SimpleOptionRenderer.tsx",
54
+ "src/components/Duration/Duration.test.tsx",
54
55
  "src/components/Duration/Duration.tsx",
55
56
  "src/components/Duration/durationUtils.ts",
56
57
  "src/components/Duration/formatDuration.spec.ts",
@@ -65,6 +66,7 @@
65
66
  "src/components/InputNumber/InputNumber.tsx",
66
67
  "src/components/InputNumber/InputNumberThousand.tsx",
67
68
  "src/components/InputNumber/__snapshots__/InputNumber.spec.tsx.snap",
69
+ "src/components/Loop/Loop.spec.tsx",
68
70
  "src/components/Loop/Loop.tsx",
69
71
  "src/components/Loop/constant.ts",
70
72
  "src/components/LunaticComponents.tsx",
@@ -98,6 +100,8 @@
98
100
  "src/components/shared/Button/IconButton.spec.tsx",
99
101
  "src/components/shared/Button/IconButton.tsx",
100
102
  "src/components/shared/Button/__snapshots__/Button.spec.tsx.snap",
103
+ "src/components/shared/CharactersCount/CharactersCount.spec.tsx",
104
+ "src/components/shared/CharactersCount/CharactersCount.tsx",
101
105
  "src/components/shared/Checkbox/CheckboxOption.spec.tsx",
102
106
  "src/components/shared/Checkbox/CheckboxOption.tsx",
103
107
  "src/components/shared/Checkbox/getShortcutKey.ts",
@@ -177,15 +181,9 @@
177
181
  "src/components/shared/Table/Tr.spec.tsx",
178
182
  "src/components/shared/Table/Tr.tsx",
179
183
  "src/components/shared/Table/index.ts",
184
+ "src/components/shared/utils/getCharactersCountId.test.ts",
185
+ "src/components/shared/utils/getCharactersCountId.ts",
180
186
  "src/components/type.ts",
181
- "src/constants/component-types.ts",
182
- "src/constants/declarations.ts",
183
- "src/constants/event-types.ts",
184
- "src/constants/index.ts",
185
- "src/constants/indexedDBStore.ts",
186
- "src/constants/supported-preferences.ts",
187
- "src/constants/value-types.ts",
188
- "src/constants/variable-types.ts",
189
187
  "src/css/components/Button.scss",
190
188
  "src/css/components/CheckboxGroup.scss",
191
189
  "src/css/components/CheckboxOne.scss",
@@ -219,7 +217,6 @@
219
217
  "src/hooks/use-auto-focus.ts",
220
218
  "src/hooks/use-track-changes.ts",
221
219
  "src/hooks/use-why-render.ts",
222
- "src/hooks/useArticulation.ts",
223
220
  "src/hooks/useDebounce.ts",
224
221
  "src/hooks/useDocumentEvent.ts",
225
222
  "src/hooks/useKeyboardKey.ts",
@@ -233,9 +230,8 @@
233
230
  "src/insee.d.ts",
234
231
  "src/stories/accordion/accordion.stories.jsx",
235
232
  "src/stories/accordion/source.json",
236
- "src/stories/behaviour/articulation/articulation.stories.tsx",
237
- "src/stories/behaviour/articulation/roundabout.json",
238
233
  "src/stories/behaviour/cleaning/cleaning.stories.jsx",
234
+ "src/stories/behaviour/cleaning/loop.json",
239
235
  "src/stories/behaviour/cleaning/source-loop.json",
240
236
  "src/stories/behaviour/cleaning/source.json",
241
237
  "src/stories/behaviour/controls/boucles-n.json",
@@ -260,6 +256,7 @@
260
256
  "src/stories/behaviour/paste/test.stories.jsx",
261
257
  "src/stories/behaviour/performance/performance.stories.jsx",
262
258
  "src/stories/behaviour/performance/source.json",
259
+ "src/stories/behaviour/performance/srcv.json",
263
260
  "src/stories/behaviour/resizing/resizing.stories.jsx",
264
261
  "src/stories/behaviour/resizing/source-resizing-cleaning.json",
265
262
  "src/stories/behaviour/resizing/source.json",
@@ -296,6 +293,7 @@
296
293
  "src/stories/input/input.stories.jsx",
297
294
  "src/stories/input/source.json",
298
295
  "src/stories/input-number/input-number.stories.jsx",
296
+ "src/stories/input-number/source-big-number.json",
299
297
  "src/stories/input-number/source-euro.json",
300
298
  "src/stories/input-number/source.json",
301
299
  "src/stories/loop/loop.stories.jsx",
@@ -369,15 +367,15 @@
369
367
  "src/stories/textarea/data.json",
370
368
  "src/stories/textarea/source.json",
371
369
  "src/stories/textarea/textarea.stories.jsx",
372
- "src/stories/utils/SchemaValidator.tsx",
370
+ "src/stories/utils/SchemaValidator.jsx",
373
371
  "src/stories/utils/custom-lunatic.scss",
374
372
  "src/stories/utils/default-arg-types.js",
375
373
  "src/stories/utils/default-args.js",
376
374
  "src/stories/utils/options.js",
375
+ "src/stories/utils/orchestrator.jsx",
377
376
  "src/stories/utils/orchestrator.scss",
378
- "src/stories/utils/orchestrator.tsx",
377
+ "src/stories/utils/overview.jsx",
379
378
  "src/stories/utils/overview.scss",
380
- "src/stories/utils/overview.tsx",
381
379
  "src/stories/utils/referentiel.js",
382
380
  "src/test.d.ts",
383
381
  "src/tests/setup.ts",
@@ -416,7 +414,9 @@
416
414
  "src/use-lunatic/commons/variables/lunatic-variables-store.spec.ts",
417
415
  "src/use-lunatic/commons/variables/lunatic-variables-store.ts",
418
416
  "src/use-lunatic/hooks/use-loop-variables.ts",
417
+ "src/use-lunatic/hooks/use-page-has-response.test.ts",
419
418
  "src/use-lunatic/hooks/use-page-has-response.ts",
419
+ "src/use-lunatic/hooks/useOverview.spec.ts",
420
420
  "src/use-lunatic/hooks/useOverview.ts",
421
421
  "src/use-lunatic/hooks/useWarnDepChange.ts",
422
422
  "src/use-lunatic/logger/ConsoleLogger.ts",
@@ -443,11 +443,13 @@
443
443
  "src/use-lunatic/reducer/reducer.ts",
444
444
  "src/use-lunatic/reducer/reducerInitializer.tsx",
445
445
  "src/use-lunatic/replace-component-sequence.ts",
446
+ "src/use-lunatic/test.utils.ts",
446
447
  "src/use-lunatic/type.ts",
447
448
  "src/use-lunatic/use-lunatic.test.ts",
448
449
  "src/use-lunatic/use-lunatic.ts",
449
450
  "src/utils/array.spec.ts",
450
451
  "src/utils/array.ts",
452
+ "src/utils/cast.ts",
451
453
  "src/utils/constants/alphabet.ts",
452
454
  "src/utils/constants/features.ts",
453
455
  "src/utils/constants/index.ts",
@@ -560,6 +562,9 @@
560
562
  "components/Loop/Loop.d.ts",
561
563
  "components/Loop/Loop.js",
562
564
  "components/Loop/Loop.js.map",
565
+ "components/Loop/Loop.spec.d.ts",
566
+ "components/Loop/Loop.spec.js",
567
+ "components/Loop/Loop.spec.js.map",
563
568
  "components/Loop/constant.d.ts",
564
569
  "components/Loop/constant.js",
565
570
  "components/Loop/constant.js.map",
@@ -647,6 +652,12 @@
647
652
  "components/shared/Button/IconButton.spec.d.ts",
648
653
  "components/shared/Button/IconButton.spec.js",
649
654
  "components/shared/Button/IconButton.spec.js.map",
655
+ "components/shared/CharactersCount/CharactersCount.d.ts",
656
+ "components/shared/CharactersCount/CharactersCount.js",
657
+ "components/shared/CharactersCount/CharactersCount.js.map",
658
+ "components/shared/CharactersCount/CharactersCount.spec.d.ts",
659
+ "components/shared/CharactersCount/CharactersCount.spec.js",
660
+ "components/shared/CharactersCount/CharactersCount.spec.js.map",
650
661
  "components/shared/Checkbox/CheckboxOption.d.ts",
651
662
  "components/shared/Checkbox/CheckboxOption.js",
652
663
  "components/shared/Checkbox/CheckboxOption.js.map",
@@ -881,33 +892,12 @@
881
892
  "components/shared/Table/index.d.ts",
882
893
  "components/shared/Table/index.js",
883
894
  "components/shared/Table/index.js.map",
895
+ "components/shared/utils/getCharactersCountId.d.ts",
896
+ "components/shared/utils/getCharactersCountId.js",
897
+ "components/shared/utils/getCharactersCountId.js.map",
884
898
  "components/type.d.ts",
885
899
  "components/type.js",
886
900
  "components/type.js.map",
887
- "constants/component-types.d.ts",
888
- "constants/component-types.js",
889
- "constants/component-types.js.map",
890
- "constants/declarations.d.ts",
891
- "constants/declarations.js",
892
- "constants/declarations.js.map",
893
- "constants/event-types.d.ts",
894
- "constants/event-types.js",
895
- "constants/event-types.js.map",
896
- "constants/index.d.ts",
897
- "constants/index.js",
898
- "constants/index.js.map",
899
- "constants/indexedDBStore.d.ts",
900
- "constants/indexedDBStore.js",
901
- "constants/indexedDBStore.js.map",
902
- "constants/supported-preferences.d.ts",
903
- "constants/supported-preferences.js",
904
- "constants/supported-preferences.js.map",
905
- "constants/value-types.d.ts",
906
- "constants/value-types.js",
907
- "constants/value-types.js.map",
908
- "constants/variable-types.d.ts",
909
- "constants/variable-types.js",
910
- "constants/variable-types.js.map",
911
901
  "esm/components/Accordion/Accordion.d.ts",
912
902
  "esm/components/Accordion/Accordion.js",
913
903
  "esm/components/Accordion/Accordion.js.map",
@@ -992,6 +982,9 @@
992
982
  "esm/components/Loop/Loop.d.ts",
993
983
  "esm/components/Loop/Loop.js",
994
984
  "esm/components/Loop/Loop.js.map",
985
+ "esm/components/Loop/Loop.spec.d.ts",
986
+ "esm/components/Loop/Loop.spec.js",
987
+ "esm/components/Loop/Loop.spec.js.map",
995
988
  "esm/components/Loop/constant.d.ts",
996
989
  "esm/components/Loop/constant.js",
997
990
  "esm/components/Loop/constant.js.map",
@@ -1079,6 +1072,12 @@
1079
1072
  "esm/components/shared/Button/IconButton.spec.d.ts",
1080
1073
  "esm/components/shared/Button/IconButton.spec.js",
1081
1074
  "esm/components/shared/Button/IconButton.spec.js.map",
1075
+ "esm/components/shared/CharactersCount/CharactersCount.d.ts",
1076
+ "esm/components/shared/CharactersCount/CharactersCount.js",
1077
+ "esm/components/shared/CharactersCount/CharactersCount.js.map",
1078
+ "esm/components/shared/CharactersCount/CharactersCount.spec.d.ts",
1079
+ "esm/components/shared/CharactersCount/CharactersCount.spec.js",
1080
+ "esm/components/shared/CharactersCount/CharactersCount.spec.js.map",
1082
1081
  "esm/components/shared/Checkbox/CheckboxOption.d.ts",
1083
1082
  "esm/components/shared/Checkbox/CheckboxOption.js",
1084
1083
  "esm/components/shared/Checkbox/CheckboxOption.js.map",
@@ -1313,33 +1312,12 @@
1313
1312
  "esm/components/shared/Table/index.d.ts",
1314
1313
  "esm/components/shared/Table/index.js",
1315
1314
  "esm/components/shared/Table/index.js.map",
1315
+ "esm/components/shared/utils/getCharactersCountId.d.ts",
1316
+ "esm/components/shared/utils/getCharactersCountId.js",
1317
+ "esm/components/shared/utils/getCharactersCountId.js.map",
1316
1318
  "esm/components/type.d.ts",
1317
1319
  "esm/components/type.js",
1318
1320
  "esm/components/type.js.map",
1319
- "esm/constants/component-types.d.ts",
1320
- "esm/constants/component-types.js",
1321
- "esm/constants/component-types.js.map",
1322
- "esm/constants/declarations.d.ts",
1323
- "esm/constants/declarations.js",
1324
- "esm/constants/declarations.js.map",
1325
- "esm/constants/event-types.d.ts",
1326
- "esm/constants/event-types.js",
1327
- "esm/constants/event-types.js.map",
1328
- "esm/constants/index.d.ts",
1329
- "esm/constants/index.js",
1330
- "esm/constants/index.js.map",
1331
- "esm/constants/indexedDBStore.d.ts",
1332
- "esm/constants/indexedDBStore.js",
1333
- "esm/constants/indexedDBStore.js.map",
1334
- "esm/constants/supported-preferences.d.ts",
1335
- "esm/constants/supported-preferences.js",
1336
- "esm/constants/supported-preferences.js.map",
1337
- "esm/constants/value-types.d.ts",
1338
- "esm/constants/value-types.js",
1339
- "esm/constants/value-types.js.map",
1340
- "esm/constants/variable-types.d.ts",
1341
- "esm/constants/variable-types.js",
1342
- "esm/constants/variable-types.js.map",
1343
1321
  "esm/hooks/use-auto-focus.d.ts",
1344
1322
  "esm/hooks/use-auto-focus.js",
1345
1323
  "esm/hooks/use-auto-focus.js.map",
@@ -1349,9 +1327,6 @@
1349
1327
  "esm/hooks/use-why-render.d.ts",
1350
1328
  "esm/hooks/use-why-render.js",
1351
1329
  "esm/hooks/use-why-render.js.map",
1352
- "esm/hooks/useArticulation.d.ts",
1353
- "esm/hooks/useArticulation.js",
1354
- "esm/hooks/useArticulation.js.map",
1355
1330
  "esm/hooks/useDebounce.d.ts",
1356
1331
  "esm/hooks/useDebounce.js",
1357
1332
  "esm/hooks/useDebounce.js.map",
@@ -1387,6 +1362,7 @@
1387
1362
  "esm/index.js.map",
1388
1363
  "esm/main.css",
1389
1364
  "esm/main.css.map",
1365
+ "esm/stories/overview/sourceWithHierarchy.json",
1390
1366
  "esm/tests/setup.d.ts",
1391
1367
  "esm/tests/setup.js",
1392
1368
  "esm/tests/setup.js.map",
@@ -1495,6 +1471,9 @@
1495
1471
  "esm/use-lunatic/hooks/useOverview.d.ts",
1496
1472
  "esm/use-lunatic/hooks/useOverview.js",
1497
1473
  "esm/use-lunatic/hooks/useOverview.js.map",
1474
+ "esm/use-lunatic/hooks/useOverview.spec.d.ts",
1475
+ "esm/use-lunatic/hooks/useOverview.spec.js",
1476
+ "esm/use-lunatic/hooks/useOverview.spec.js.map",
1498
1477
  "esm/use-lunatic/hooks/useWarnDepChange.d.ts",
1499
1478
  "esm/use-lunatic/hooks/useWarnDepChange.js",
1500
1479
  "esm/use-lunatic/hooks/useWarnDepChange.js.map",
@@ -1570,6 +1549,9 @@
1570
1549
  "esm/use-lunatic/replace-component-sequence.d.ts",
1571
1550
  "esm/use-lunatic/replace-component-sequence.js",
1572
1551
  "esm/use-lunatic/replace-component-sequence.js.map",
1552
+ "esm/use-lunatic/test.utils.d.ts",
1553
+ "esm/use-lunatic/test.utils.js",
1554
+ "esm/use-lunatic/test.utils.js.map",
1573
1555
  "esm/use-lunatic/type.d.ts",
1574
1556
  "esm/use-lunatic/type.js",
1575
1557
  "esm/use-lunatic/type.js.map",
@@ -1582,6 +1564,9 @@
1582
1564
  "esm/utils/array.spec.d.ts",
1583
1565
  "esm/utils/array.spec.js",
1584
1566
  "esm/utils/array.spec.js.map",
1567
+ "esm/utils/cast.d.ts",
1568
+ "esm/utils/cast.js",
1569
+ "esm/utils/cast.js.map",
1585
1570
  "esm/utils/constants/alphabet.d.ts",
1586
1571
  "esm/utils/constants/alphabet.js",
1587
1572
  "esm/utils/constants/alphabet.js.map",
@@ -1675,9 +1660,6 @@
1675
1660
  "hooks/use-why-render.d.ts",
1676
1661
  "hooks/use-why-render.js",
1677
1662
  "hooks/use-why-render.js.map",
1678
- "hooks/useArticulation.d.ts",
1679
- "hooks/useArticulation.js",
1680
- "hooks/useArticulation.js.map",
1681
1663
  "hooks/useDebounce.d.ts",
1682
1664
  "hooks/useDebounce.js",
1683
1665
  "hooks/useDebounce.js.map",
@@ -1713,6 +1695,7 @@
1713
1695
  "index.js.map",
1714
1696
  "main.css",
1715
1697
  "main.css.map",
1698
+ "stories/overview/sourceWithHierarchy.json",
1716
1699
  "tests/setup.d.ts",
1717
1700
  "tests/setup.js",
1718
1701
  "tests/setup.js.map",
@@ -1822,6 +1805,9 @@
1822
1805
  "use-lunatic/hooks/useOverview.d.ts",
1823
1806
  "use-lunatic/hooks/useOverview.js",
1824
1807
  "use-lunatic/hooks/useOverview.js.map",
1808
+ "use-lunatic/hooks/useOverview.spec.d.ts",
1809
+ "use-lunatic/hooks/useOverview.spec.js",
1810
+ "use-lunatic/hooks/useOverview.spec.js.map",
1825
1811
  "use-lunatic/hooks/useWarnDepChange.d.ts",
1826
1812
  "use-lunatic/hooks/useWarnDepChange.js",
1827
1813
  "use-lunatic/hooks/useWarnDepChange.js.map",
@@ -1897,6 +1883,9 @@
1897
1883
  "use-lunatic/replace-component-sequence.d.ts",
1898
1884
  "use-lunatic/replace-component-sequence.js",
1899
1885
  "use-lunatic/replace-component-sequence.js.map",
1886
+ "use-lunatic/test.utils.d.ts",
1887
+ "use-lunatic/test.utils.js",
1888
+ "use-lunatic/test.utils.js.map",
1900
1889
  "use-lunatic/type.d.ts",
1901
1890
  "use-lunatic/type.js",
1902
1891
  "use-lunatic/type.js.map",
@@ -1909,6 +1898,9 @@
1909
1898
  "utils/array.spec.d.ts",
1910
1899
  "utils/array.spec.js",
1911
1900
  "utils/array.spec.js.map",
1901
+ "utils/cast.d.ts",
1902
+ "utils/cast.js",
1903
+ "utils/cast.js.map",
1912
1904
  "utils/constants/alphabet.d.ts",
1913
1905
  "utils/constants/alphabet.js",
1914
1906
  "utils/constants/alphabet.js.map",
@@ -118,7 +118,7 @@ export const CustomDatepicker = slottableComponent<CustomProps>(
118
118
  <DatepickerField
119
119
  id={id + 'month'}
120
120
  label="Mois"
121
- description="Exemple: 07"
121
+ description="Exemple: 7"
122
122
  max={12}
123
123
  value={numbers[1]}
124
124
  onChange={setNumber(1)}
@@ -52,7 +52,7 @@ exports[`Datepicker > should render properly with format YYYY-MM 1`] = `
52
52
  <span
53
53
  class="lunaticDatepickerHint"
54
54
  >
55
- Exemple: 07
55
+ Exemple: 7
56
56
  </span>
57
57
  </label>
58
58
  <input
@@ -128,7 +128,7 @@ exports[`Datepicker > should render properly with format YYYY-MM-DD 1`] = `
128
128
  <span
129
129
  class="lunaticDatepickerHint"
130
130
  >
131
- Exemple: 07
131
+ Exemple: 7
132
132
  </span>
133
133
  </label>
134
134
  <input
@@ -0,0 +1,52 @@
1
+ import { afterEach, describe, expect, it, vi } from 'vitest';
2
+ import { Duration } from './Duration';
3
+ import { render } from '@testing-library/react';
4
+ import { Formats } from './durationUtils';
5
+
6
+ describe('Duration', () => {
7
+ const mockOnChange = vi.fn();
8
+
9
+ const baseDeclarations = [
10
+ {
11
+ id: '1',
12
+ label: 'Declaration 1',
13
+ declarationType: 'COMMENT' as const,
14
+ position: 'AFTER_QUESTION_TEXT',
15
+ },
16
+ {
17
+ id: '2',
18
+ label: 'Declaration 2',
19
+ declarationType: 'COMMENT' as const,
20
+ position: 'AFTER_QUESTION_TEXT',
21
+ },
22
+ ];
23
+
24
+ const baseProps = {
25
+ handleChanges: mockOnChange,
26
+ response: { name: 'demo' },
27
+ format: 'PTnHnM' as Formats,
28
+ value: 'PT5H1M',
29
+ id: 'duration',
30
+ label: 'label',
31
+ description: 'description',
32
+ declarations: baseDeclarations,
33
+ };
34
+
35
+ afterEach(() => {
36
+ vi.clearAllMocks();
37
+ });
38
+
39
+ it('renders label, declarations and description', () => {
40
+ const { getByText } = render(<Duration {...baseProps} />);
41
+
42
+ // label is displayed
43
+ expect(getByText(baseProps.label)).toBeInTheDocument();
44
+
45
+ // all declarations are displayed
46
+ expect(getByText('Declaration 1')).toBeInTheDocument();
47
+ expect(getByText('Declaration 2')).toBeInTheDocument();
48
+
49
+ // description is displayed
50
+ expect(getByText(baseProps.description)).toBeInTheDocument();
51
+ });
52
+ });
@@ -12,6 +12,7 @@ import {
12
12
  getComponentErrors,
13
13
  } from '../shared/ComponentErrors/ComponentErrors';
14
14
  import { Declarations } from '../shared/Declarations/Declarations';
15
+ import { Fieldset } from '../shared/Fieldset/Fieldset';
15
16
 
16
17
  export function Duration({
17
18
  handleChanges,
@@ -39,7 +40,16 @@ type CustomProps = Omit<
39
40
  export const CustomDuration = slottableComponent<CustomProps>(
40
41
  'Duration',
41
42
  (props) => {
42
- const { errors, value, label, format, onChange, declarations, id } = props;
43
+ const {
44
+ errors,
45
+ value,
46
+ label,
47
+ format,
48
+ onChange,
49
+ declarations,
50
+ id,
51
+ description,
52
+ } = props;
43
53
  // We need to keep an internal state since one field can be empty (null value in duration)
44
54
  // but we still send "0" and we don't want the field to display "0"
45
55
  const [duration, setDuration] = useState(
@@ -66,8 +76,11 @@ export const CustomDuration = slottableComponent<CustomProps>(
66
76
  };
67
77
 
68
78
  return (
69
- <fieldset className={classnames('lunatic-input')}>
70
- {label && <legend>{label}</legend>}
79
+ <Fieldset
80
+ className={classnames('lunatic-input')}
81
+ legend={label}
82
+ description={description}
83
+ >
71
84
  <Declarations
72
85
  type="AFTER_QUESTION_TEXT"
73
86
  declarations={declarations}
@@ -91,7 +104,7 @@ export const CustomDuration = slottableComponent<CustomProps>(
91
104
  ))}
92
105
  </div>
93
106
  <ComponentErrors errors={errors} />
94
- </fieldset>
107
+ </Fieldset>
95
108
  );
96
109
  }
97
110
  );
@@ -1,6 +1,12 @@
1
1
  import { fireEvent, render, screen } from '@testing-library/react';
2
2
  import { beforeEach, describe, expect, it, vi } from 'vitest';
3
3
  import { Input } from './Input';
4
+ import { CharactersCount } from '../shared/CharactersCount/CharactersCount';
5
+
6
+ vi.mock('../shared/CharactersCount/CharactersCount', () => ({
7
+ CharactersCount: vi.fn(),
8
+ }));
9
+
4
10
  describe('Input', () => {
5
11
  const mockOnChange = vi.fn();
6
12
  const baseProps = {
@@ -34,6 +40,19 @@ describe('Input', () => {
34
40
  expect(input).toBeInTheDocument();
35
41
  });
36
42
 
43
+ it('calls CharactersCount component with correct props', () => {
44
+ const props = { ...baseProps, maxLength: 30 };
45
+ render(<Input {...props} />);
46
+ expect(CharactersCount).toHaveBeenCalledWith(
47
+ {
48
+ id: props.id,
49
+ maxLength: props.maxLength,
50
+ value: props.value,
51
+ },
52
+ {}
53
+ );
54
+ });
55
+
37
56
  it('calls onChange with parsed value', () => {
38
57
  const { container } = render(<Input {...baseProps} errors={undefined} />);
39
58
 
@@ -73,4 +92,19 @@ describe('Input', () => {
73
92
  expect(input).toHaveFocus();
74
93
  expect(input).toHaveValue('toto');
75
94
  });
95
+
96
+ it('should display input value from the start when user leave input', () => {
97
+ const setSelectionRangeMock = vi.fn();
98
+ const { container } = render(<Input {...baseProps} />);
99
+
100
+ const input = container.querySelector('input[type="text"]');
101
+
102
+ fireEvent.blur(input!, {
103
+ target: {
104
+ ...input,
105
+ setSelectionRange: setSelectionRangeMock,
106
+ },
107
+ });
108
+ expect(setSelectionRangeMock).toHaveBeenCalledWith(0, 0);
109
+ });
76
110
  });
@@ -8,6 +8,8 @@ import {
8
8
  } from '../shared/ComponentErrors/ComponentErrors';
9
9
  import { Declarations } from '../shared/Declarations/Declarations';
10
10
  import type { LunaticError } from '../../use-lunatic/type';
11
+ import { CharactersCount } from '../shared/CharactersCount/CharactersCount';
12
+ import { getCharactersCountId } from '../shared/utils/getCharactersCountId';
11
13
 
12
14
  export function Input({
13
15
  handleChanges,
@@ -47,6 +49,8 @@ export const CustomInput = slottableComponent<CustomProps>('Input', (props) => {
47
49
  declarations,
48
50
  } = props;
49
51
  const labelId = `label-${id}`;
52
+ const charactersCountId = getCharactersCountId(id, maxLength);
53
+
50
54
  return (
51
55
  <div className={classnames('lunatic-input')}>
52
56
  <Label htmlFor={id} id={labelId} description={description}>
@@ -57,24 +61,28 @@ export const CustomInput = slottableComponent<CustomProps>('Input', (props) => {
57
61
  declarations={declarations}
58
62
  id={id}
59
63
  />
60
- <input
61
- id={id}
62
- aria-labelledby={labelId}
63
- autoComplete="off"
64
- type="text"
65
- disabled={disabled}
66
- readOnly={readOnly}
67
- value={(value ?? '').toString()}
68
- title={value ?? ''}
69
- onChange={(e) => onChange(e.target.value)}
70
- aria-required={required}
71
- required={required}
72
- maxLength={maxLength}
73
- aria-invalid={!!errors}
74
- onBlur={(e) => {
75
- e.target.setSelectionRange(0, 0);
76
- }}
77
- />
64
+ <div className="field-with-count">
65
+ <input
66
+ id={id}
67
+ aria-labelledby={labelId}
68
+ aria-describedby={maxLength ? charactersCountId : undefined}
69
+ autoComplete="off"
70
+ type="text"
71
+ disabled={disabled}
72
+ readOnly={readOnly}
73
+ value={(value ?? '').toString()}
74
+ title={value ?? ''}
75
+ onChange={(e) => onChange(e.target.value)}
76
+ aria-required={required}
77
+ required={required}
78
+ maxLength={maxLength}
79
+ aria-invalid={!!errors}
80
+ onBlur={(e) => {
81
+ e.target.setSelectionRange(0, 0);
82
+ }}
83
+ />
84
+ <CharactersCount id={id} maxLength={maxLength} value={value} />
85
+ </div>
78
86
  <ComponentErrors errors={errors} />
79
87
  </div>
80
88
  );
@@ -5,15 +5,30 @@ exports[`Input > renders without crashing 1`] = `
5
5
  <div
6
6
  class="lunatic-input"
7
7
  >
8
- <input
9
- aria-invalid="false"
10
- aria-labelledby="label-input"
11
- autocomplete="off"
12
- id="input"
13
- title="input"
14
- type="text"
15
- value="input"
16
- />
8
+ <label
9
+ class="lunatic-label"
10
+ for="input"
11
+ id="label-input"
12
+ >
13
+ <span
14
+ class="label-description"
15
+ >
16
+ description
17
+ </span>
18
+ </label>
19
+ <div
20
+ class="field-with-count"
21
+ >
22
+ <input
23
+ aria-invalid="false"
24
+ aria-labelledby="label-input"
25
+ autocomplete="off"
26
+ id="input"
27
+ title="input"
28
+ type="text"
29
+ value="input"
30
+ />
31
+ </div>
17
32
  </div>
18
33
  </div>
19
34
  `;
@@ -23,16 +38,20 @@ exports[`Input > should handle readOnly 1`] = `
23
38
  <div
24
39
  class="lunatic-input"
25
40
  >
26
- <input
27
- aria-invalid="false"
28
- aria-labelledby="label-number"
29
- autocomplete="off"
30
- id="number"
31
- readonly=""
32
- title="toto"
33
- type="text"
34
- value="toto"
35
- />
41
+ <div
42
+ class="field-with-count"
43
+ >
44
+ <input
45
+ aria-invalid="false"
46
+ aria-labelledby="label-number"
47
+ autocomplete="off"
48
+ id="number"
49
+ readonly=""
50
+ title="toto"
51
+ type="text"
52
+ value="toto"
53
+ />
54
+ </div>
36
55
  </div>
37
56
  </div>
38
57
  `;