@inseefr/lunatic 3.5.6 → 3.5.8

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 (245) hide show
  1. package/components/CheckboxOne/CheckboxOne.spec.js +3 -2
  2. package/components/CheckboxOne/CheckboxOne.spec.js.map +1 -1
  3. package/components/shared/Combobox/Combobox.stories.d.ts +3 -2
  4. package/components/shared/Combobox/Combobox.stories.js +26 -21
  5. package/components/shared/Combobox/Combobox.stories.js.map +1 -1
  6. package/components/type.d.ts +3 -0
  7. package/esm/components/CheckboxOne/CheckboxOne.spec.js +3 -2
  8. package/esm/components/CheckboxOne/CheckboxOne.spec.js.map +1 -1
  9. package/esm/components/shared/Combobox/Combobox.stories.d.ts +3 -2
  10. package/esm/components/shared/Combobox/Combobox.stories.js +28 -24
  11. package/esm/components/shared/Combobox/Combobox.stories.js.map +1 -1
  12. package/esm/components/type.d.ts +3 -0
  13. package/esm/hooks/useLocalStorage.d.ts +1 -0
  14. package/esm/hooks/useLocalStorage.js +31 -0
  15. package/esm/hooks/useLocalStorage.js.map +1 -0
  16. package/esm/type.source.d.ts +6 -0
  17. package/esm/use-lunatic/commons/compile-controls.js +22 -14
  18. package/esm/use-lunatic/commons/compile-controls.js.map +1 -1
  19. package/esm/use-lunatic/commons/fill-components/fill-component-expressions.js +4 -1
  20. package/esm/use-lunatic/commons/fill-components/fill-component-expressions.js.map +1 -1
  21. package/esm/use-lunatic/hooks/use-page-has-response.js +1 -1
  22. package/esm/use-lunatic/hooks/use-page-has-response.js.map +1 -1
  23. package/esm/use-lunatic/hooks/useOverview.spec.js +2 -2
  24. package/esm/use-lunatic/hooks/useOverview.spec.js.map +1 -1
  25. package/esm/use-lunatic/props/getComponentTypeProps.d.ts +3 -0
  26. package/esm/utils/number.d.ts +4 -0
  27. package/esm/utils/number.js +12 -0
  28. package/esm/utils/number.js.map +1 -1
  29. package/esm/utils/object.d.ts +10 -0
  30. package/esm/utils/object.js +26 -0
  31. package/esm/utils/object.js.map +1 -1
  32. package/hooks/useLocalStorage.d.ts +1 -0
  33. package/hooks/useLocalStorage.js +34 -0
  34. package/hooks/useLocalStorage.js.map +1 -0
  35. package/package.json +76 -137
  36. package/src/components/CheckboxOne/CheckboxOne.spec.tsx +3 -0
  37. package/src/components/shared/Combobox/Combobox.stories.tsx +48 -49
  38. package/src/components/type.ts +1 -0
  39. package/src/hooks/useLocalStorage.ts +37 -0
  40. package/src/json.d.ts +16 -0
  41. package/src/stories/accordion/accordion.stories.tsx +21 -0
  42. package/src/stories/behaviour/cleaning/cleaning.stories.tsx +40 -0
  43. package/src/stories/behaviour/controls/controls.stories.tsx +51 -0
  44. package/src/stories/behaviour/disabled/disabled.stories.tsx +29 -0
  45. package/src/stories/behaviour/filter/filter.stories.tsx +34 -0
  46. package/src/stories/behaviour/missing/missing.stories.tsx +31 -0
  47. package/src/stories/behaviour/overview/overview.stories.tsx +61 -0
  48. package/src/stories/{overview/sourceWithHierarchy.json → behaviour/overview/source.json} +1 -1
  49. package/src/stories/{overview → behaviour/overview}/sourceLoop.json +1 -1
  50. package/src/stories/behaviour/performance/performance.stories.tsx +29 -0
  51. package/src/stories/behaviour/resizing/resizing.stories.tsx +34 -0
  52. package/src/stories/behaviour/slots.stories.tsx +34 -0
  53. package/src/stories/checkbox/checkbox.stories.tsx +75 -0
  54. package/src/stories/{checkbox-group/sourceLoop.json → checkbox/sourceGroupLoop.json} +1 -1
  55. package/src/stories/datepicker/datepicker.stories.tsx +21 -0
  56. package/src/stories/declaration/declaration.stories.tsx +27 -0
  57. package/src/stories/dropdown/dropdown.stories.tsx +27 -0
  58. package/src/stories/duration/duration.stories.tsx +27 -0
  59. package/src/stories/filter-description/filter-description.stories.tsx +28 -0
  60. package/src/stories/input/input.stories.tsx +21 -0
  61. package/src/stories/input-number/input-number.stories.tsx +35 -0
  62. package/src/stories/loop/loop.stories.tsx +35 -0
  63. package/src/stories/loop/roster-for-loop.stories.tsx +59 -0
  64. package/src/stories/pairwise/pairwise.stories.tsx +30 -0
  65. package/src/stories/paste.stories.tsx +85 -0
  66. package/src/stories/question/question.stories.tsx +21 -0
  67. package/src/stories/questionnaires/logement/logement.stories.tsx +26 -0
  68. package/src/stories/questionnaires/recensement/recensement.stories.tsx +28 -0
  69. package/src/stories/questionnaires/rp/rp.stories.tsx +21 -0
  70. package/src/stories/questionnaires/simpsons/simpsons.stories.tsx +31 -0
  71. package/src/stories/radio/radio.stories.tsx +53 -0
  72. package/src/stories/roundabout/roundabout.stories.tsx +37 -0
  73. package/src/stories/roundabout/source.json +1 -0
  74. package/src/stories/sequence/sequence.stories.tsx +28 -0
  75. package/src/stories/suggester/source-option-responses.json +1 -1
  76. package/src/stories/suggester/suggester.stories.tsx +68 -0
  77. package/src/stories/summary/source.json +22 -1
  78. package/src/stories/summary/summary.stories.tsx +31 -0
  79. package/src/stories/table/table.stories.tsx +35 -0
  80. package/src/stories/text/text.stories.tsx +38 -0
  81. package/src/stories/textarea/textarea.stories.tsx +21 -0
  82. package/src/stories/utils/Orchestrator.tsx +310 -0
  83. package/src/stories/utils/OrchestratorData.tsx +176 -0
  84. package/src/stories/utils/OrchestratorOverview.tsx +70 -0
  85. package/src/stories/utils/OrchestratorSidebar.tsx +119 -0
  86. package/src/stories/utils/SchemaValidator.tsx +29 -0
  87. package/src/stories/utils/referentiel.ts +9 -0
  88. package/src/type.source.ts +6 -0
  89. package/src/use-lunatic/commons/compile-controls.ts +36 -18
  90. package/src/use-lunatic/commons/fill-components/fill-component-expressions.ts +4 -1
  91. package/src/use-lunatic/hooks/use-page-has-response.ts +1 -1
  92. package/src/use-lunatic/hooks/useOverview.spec.ts +3 -2
  93. package/src/use-lunatic/use-lunatic.test.ts +53 -40
  94. package/src/utils/number.ts +13 -0
  95. package/src/utils/object.ts +40 -0
  96. package/tsconfig.build.tsbuildinfo +1 -1
  97. package/type.source.d.ts +6 -0
  98. package/use-lunatic/commons/compile-controls.js +21 -13
  99. package/use-lunatic/commons/compile-controls.js.map +1 -1
  100. package/use-lunatic/commons/fill-components/fill-component-expressions.js +5 -2
  101. package/use-lunatic/commons/fill-components/fill-component-expressions.js.map +1 -1
  102. package/use-lunatic/hooks/use-page-has-response.js +2 -2
  103. package/use-lunatic/hooks/use-page-has-response.js.map +1 -1
  104. package/use-lunatic/hooks/useOverview.spec.js +8 -8
  105. package/use-lunatic/hooks/useOverview.spec.js.map +1 -1
  106. package/use-lunatic/props/getComponentTypeProps.d.ts +3 -0
  107. package/utils/number.d.ts +4 -0
  108. package/utils/number.js +13 -0
  109. package/utils/number.js.map +1 -1
  110. package/utils/object.d.ts +10 -0
  111. package/utils/object.js +30 -0
  112. package/utils/object.js.map +1 -1
  113. package/esm/stories/overview/sourceWithHierarchy.json +0 -5151
  114. package/esm/tests/utils/lunatic.d.ts +0 -15
  115. package/esm/tests/utils/lunatic.js +0 -27
  116. package/esm/tests/utils/lunatic.js.map +0 -1
  117. package/esm/use-lunatic/replace-component-sequence.d.ts +0 -36
  118. package/esm/use-lunatic/replace-component-sequence.js +0 -19
  119. package/esm/use-lunatic/replace-component-sequence.js.map +0 -1
  120. package/esm/use-lunatic/test.utils.d.ts +0 -2
  121. package/esm/use-lunatic/test.utils.js +0 -13
  122. package/esm/use-lunatic/test.utils.js.map +0 -1
  123. package/esm/utils/is-object.d.ts +0 -4
  124. package/esm/utils/is-object.js +0 -7
  125. package/esm/utils/is-object.js.map +0 -1
  126. package/esm/utils/to-number.d.ts +0 -4
  127. package/esm/utils/to-number.js +0 -13
  128. package/esm/utils/to-number.js.map +0 -1
  129. package/src/stories/accordion/accordion.stories.jsx +0 -17
  130. package/src/stories/behaviour/cleaning/cleaning.stories.jsx +0 -69
  131. package/src/stories/behaviour/controls/controls.stories.jsx +0 -81
  132. package/src/stories/behaviour/filter/dataLoop.json +0 -14
  133. package/src/stories/behaviour/filter/filter.stories.jsx +0 -36
  134. package/src/stories/behaviour/missing/missing.stories.jsx +0 -69
  135. package/src/stories/behaviour/others/V2_DeclarationsSimples.json +0 -908
  136. package/src/stories/behaviour/others/V2_MinMaxSum_Boucles.json +0 -489
  137. package/src/stories/behaviour/others/V2_QuestSimple_Boucles.json +0 -3919
  138. package/src/stories/behaviour/others/V2_TCMRallyeGames.json +0 -2760
  139. package/src/stories/behaviour/others/test-dylan.json +0 -538
  140. package/src/stories/behaviour/others/test.stories.jsx +0 -78
  141. package/src/stories/behaviour/paste/source.json +0 -32
  142. package/src/stories/behaviour/paste/test.stories.jsx +0 -62
  143. package/src/stories/behaviour/performance/performance.stories.jsx +0 -26
  144. package/src/stories/behaviour/resizing/resizing.stories.jsx +0 -60
  145. package/src/stories/behaviour/slots.stories.jsx +0 -32
  146. package/src/stories/checkbox-boolean/checkboxBoolean.stories.jsx +0 -17
  147. package/src/stories/checkbox-group/checkbox-group.stories.jsx +0 -77
  148. package/src/stories/checkbox-one/checkboxOne.stories.jsx +0 -53
  149. package/src/stories/date-picker/data.json +0 -3
  150. package/src/stories/date-picker/datepicker.stories.jsx +0 -26
  151. package/src/stories/declaration/data.json +0 -1
  152. package/src/stories/declaration/input.stories.jsx +0 -18
  153. package/src/stories/disabled/data.json +0 -16
  154. package/src/stories/disabled/disabled.stories.jsx +0 -18
  155. package/src/stories/dropdown/data.json +0 -8
  156. package/src/stories/dropdown/dropdown.stories.jsx +0 -25
  157. package/src/stories/duration/duration.stories.jsx +0 -25
  158. package/src/stories/filter-description/filter-description.stories.jsx +0 -37
  159. package/src/stories/input/data.json +0 -1
  160. package/src/stories/input/input.stories.jsx +0 -18
  161. package/src/stories/input-number/input-number.stories.jsx +0 -23
  162. package/src/stories/loop/loop.stories.jsx +0 -29
  163. package/src/stories/loop/roster-for-loop.stories.jsx +0 -46
  164. package/src/stories/markdown/markdown.stories.jsx +0 -20
  165. package/src/stories/overview/data.json +0 -1
  166. package/src/stories/overview/dataLoop.json +0 -93
  167. package/src/stories/overview/overview.stories.jsx +0 -44
  168. package/src/stories/overview/source.json +0 -25
  169. package/src/stories/pairwise/data.json +0 -12
  170. package/src/stories/pairwise/pairwise-links.stories.jsx +0 -48
  171. package/src/stories/question/question.stories.jsx +0 -16
  172. package/src/stories/questionnaires/logement/logement.stories.jsx +0 -59
  173. package/src/stories/questionnaires/recensement/data.json +0 -12
  174. package/src/stories/questionnaires/recensement/recensement.stories.jsx +0 -35
  175. package/src/stories/questionnaires/rp/data.json +0 -5
  176. package/src/stories/questionnaires/rp/rp.stories.jsx +0 -23
  177. package/src/stories/questionnaires/simpsons/simpsons.stories.jsx +0 -246
  178. package/src/stories/radio/radio.stories.jsx +0 -78
  179. package/src/stories/roundabout/data1.json +0 -13
  180. package/src/stories/roundabout/data2.json +0 -16
  181. package/src/stories/roundabout/roundabout.stories.jsx +0 -32
  182. package/src/stories/sequence/sequence.stories.jsx +0 -29
  183. package/src/stories/suggester/suggester.stories.jsx +0 -71
  184. package/src/stories/summary/data.json +0 -16
  185. package/src/stories/summary/summary.stories.jsx +0 -23
  186. package/src/stories/switch/README.md +0 -29
  187. package/src/stories/switch/data-forced.json +0 -40
  188. package/src/stories/switch/source.json +0 -64
  189. package/src/stories/switch/switch.stories.jsx +0 -17
  190. package/src/stories/table/data.json +0 -1
  191. package/src/stories/table/table.stories.jsx +0 -30
  192. package/src/stories/text/data-roster.json +0 -5
  193. package/src/stories/text/text.stories.jsx +0 -20
  194. package/src/stories/textarea/data.json +0 -1
  195. package/src/stories/textarea/textarea.stories.jsx +0 -18
  196. package/src/stories/utils/SchemaValidator.jsx +0 -40
  197. package/src/stories/utils/default-arg-types.js +0 -39
  198. package/src/stories/utils/default-args.js +0 -3
  199. package/src/stories/utils/options.js +0 -19
  200. package/src/stories/utils/orchestrator.jsx +0 -267
  201. package/src/stories/utils/orchestrator.scss +0 -66
  202. package/src/stories/utils/overview.jsx +0 -39
  203. package/src/stories/utils/overview.scss +0 -37
  204. package/src/stories/utils/referentiel.js +0 -7
  205. package/src/tests/utils/e2e.js +0 -91
  206. package/src/tests/utils/lunatic.ts +0 -33
  207. package/src/use-lunatic/replace-component-sequence.ts +0 -25
  208. package/src/use-lunatic/test.utils.ts +0 -17
  209. package/src/utils/is-object.ts +0 -6
  210. package/src/utils/to-number.ts +0 -12
  211. package/stories/overview/sourceWithHierarchy.json +0 -5151
  212. package/tests/utils/lunatic.d.ts +0 -15
  213. package/tests/utils/lunatic.js +0 -31
  214. package/tests/utils/lunatic.js.map +0 -1
  215. package/use-lunatic/replace-component-sequence.d.ts +0 -36
  216. package/use-lunatic/replace-component-sequence.js +0 -22
  217. package/use-lunatic/replace-component-sequence.js.map +0 -1
  218. package/use-lunatic/test.utils.d.ts +0 -2
  219. package/use-lunatic/test.utils.js +0 -17
  220. package/use-lunatic/test.utils.js.map +0 -1
  221. package/utils/is-object.d.ts +0 -4
  222. package/utils/is-object.js +0 -10
  223. package/utils/is-object.js.map +0 -1
  224. package/utils/to-number.d.ts +0 -4
  225. package/utils/to-number.js +0 -16
  226. package/utils/to-number.js.map +0 -1
  227. /package/src/stories/behaviour/cleaning/{loop.json → source-loop-scopes.json} +0 -0
  228. /package/src/stories/behaviour/controls/{boucles-n.json → source-boucles-n.json} +0 -0
  229. /package/src/stories/behaviour/controls/{loop.json → source-loop.json} +0 -0
  230. /package/src/stories/behaviour/controls/{roundabout.json → source-roundabout.json} +0 -0
  231. /package/src/stories/behaviour/controls/{simple-numeric.json → source-simple-numeric.json} +0 -0
  232. /package/src/stories/behaviour/controls/{simple.json → source-simple.json} +0 -0
  233. /package/src/stories/{disabled → behaviour/disabled}/source.json +0 -0
  234. /package/src/stories/{checkbox-boolean → checkbox}/source.json +0 -0
  235. /package/src/stories/{checkbox-group/source.json → checkbox/sourceGroup.json} +0 -0
  236. /package/src/stories/{checkbox-group/sourceCondition.json → checkbox/sourceGroupCondition.json} +0 -0
  237. /package/src/stories/{checkbox-group/sourceDetail.json → checkbox/sourceGroupDetail.json} +0 -0
  238. /package/src/stories/{checkbox-one/source.json → checkbox/sourceOne.json} +0 -0
  239. /package/src/stories/{checkbox-one/sourceDetail.json → checkbox/sourceOneDetail.json} +0 -0
  240. /package/src/stories/{date-picker → datepicker}/source.json +0 -0
  241. /package/src/stories/{markdown/source.json → declaration/sourceMarkdown.json} +0 -0
  242. /package/src/stories/duration/{mois.json → sourceMonths.json} +0 -0
  243. /package/src/stories/duration/{time.json → sourceTime.json} +0 -0
  244. /package/src/stories/filter-description/{source-options.json → sourceOptions.json} +0 -0
  245. /package/src/stories/table/{table-dynamique.json → source-dynamic.json} +0 -0
@@ -1,267 +0,0 @@
1
- import './custom-lunatic.scss';
2
- import './orchestrator.scss';
3
-
4
- import {
5
- Button,
6
- components,
7
- LunaticComponents,
8
- ModalControls,
9
- useLunatic,
10
- } from '../..';
11
- import React, { memo, useCallback, useEffect, useMemo, useState } from 'react';
12
-
13
- import { Logger } from '../../utils/logger';
14
- import { Overview } from './overview';
15
- import { SchemaValidator } from './SchemaValidator.jsx';
16
-
17
- const Input = components.Input;
18
-
19
- function DevOptions({ goToPage, getData }) {
20
- const [toPage, setToPage] = useState(1);
21
-
22
- function handleChange(_, value) {
23
- setToPage(value);
24
- }
25
-
26
- return (
27
- <div className="dev-options">
28
- <div style={{ display: 'flex' }}>
29
- <Button onClick={() => Logger.log(getData(true))}>Get Data</Button>
30
- <Button onClick={() => goToPage({ page: `${toPage}` })}>
31
- {`Go to "${toPage}"`}
32
- </Button>
33
- </div>
34
- <Input
35
- id="page-to-jump"
36
- value={toPage}
37
- handleChange={handleChange}
38
- min={1}
39
- label={'Page to reach : '}
40
- />
41
- </div>
42
- );
43
- }
44
-
45
- function Pager({
46
- goPrevious,
47
- goNext,
48
- goToPage,
49
- lastReachedPage,
50
- isLast,
51
- isFirst,
52
- pageTag,
53
- maxPage,
54
- getData,
55
- pager,
56
- }) {
57
- return (
58
- <>
59
- <div className="pagination">
60
- <Button onClick={goPrevious} disabled={isFirst}>
61
- Previous
62
- </Button>
63
- <Button onClick={goNext} disabled={isLast}>
64
- Next
65
- </Button>
66
- <div style={{ fontSize: '.8em', opacity: 0.7, marginTop: '.3em' }}>
67
- You can use PgDown / PgUp shortcut
68
- </div>
69
- </div>
70
- <DevOptions
71
- goToPage={goToPage}
72
- getData={getData}
73
- lastReachedPage={lastReachedPage}
74
- />
75
- <div className="story-pager">
76
- <h3>Pager</h3>
77
- <ul>
78
- <li>
79
- <strong>PageTag:</strong> {JSON.stringify(pageTag)}
80
- </li>
81
- {Object.keys(pager).map((key) => (
82
- <li key={key}>
83
- <strong>{key}:</strong> {JSON.stringify(pager[key])}
84
- </li>
85
- ))}
86
- </ul>
87
- </div>
88
- </>
89
- );
90
- }
91
-
92
- function onLogChange(response, value, args) {
93
- Logger.log('onChange', { response, value, args });
94
- }
95
-
96
- function logMissingStrategy() {
97
- Logger.log('no missing strategy');
98
- }
99
-
100
- function OrchestratorForStories({
101
- source,
102
- data,
103
- disableFilters = false,
104
- disableFiltersDescription = true,
105
- management = false,
106
- shortcut = false,
107
- activeControls = false,
108
- features,
109
- initialPage = '1',
110
- missing = false,
111
- missingStrategy = logMissingStrategy,
112
- missingShortcut,
113
- autoSuggesterLoading,
114
- addExternal,
115
- preferences,
116
- slots,
117
- showOverview = false,
118
- getReferentiel,
119
- dontKnowButton,
120
- refusedButton,
121
- readOnly = false,
122
- disabled = false,
123
- detailAlwaysDisplayed = false,
124
- ...rest
125
- }) {
126
- const { maxPage } = source;
127
-
128
- const componentsOptions = { detailAlwaysDisplayed };
129
-
130
- const {
131
- getComponents,
132
- goPreviousPage,
133
- goNextPage,
134
- goToPage,
135
- pager,
136
- pageTag,
137
- isFirstPage,
138
- isLastPage,
139
- waiting,
140
- overview,
141
- compileControls,
142
- getData,
143
- Provider,
144
- hasPageResponse,
145
- } = useLunatic(source, data, {
146
- initialPage,
147
- features,
148
- preferences,
149
- disableFilters,
150
- disableFiltersDescription,
151
- onChange: onLogChange,
152
- autoSuggesterLoading,
153
- getReferentiel,
154
- management,
155
- missing,
156
- missingStrategy,
157
- lastReachedPage: rest.lastReachedPage,
158
- missingShortcut,
159
- shortcut,
160
- activeControls,
161
- withOverview: showOverview,
162
- dontKnowButton,
163
- refusedButton,
164
- componentsOptions,
165
- });
166
-
167
- const components = getComponents();
168
- const { lastReachedPage } = pager;
169
-
170
- const [errorActive, setErrorActive] = useState({});
171
- const [errorsForModal, setErrorsForModal] = useState(null);
172
-
173
- const skip = useCallback(
174
- (arg) => {
175
- setErrorsForModal(undefined);
176
- goNextPage(arg);
177
- },
178
- [goNextPage]
179
- );
180
-
181
- const closeModal = useCallback(() => setErrorsForModal(undefined), []);
182
-
183
- const handleGoNext = useCallback(() => {
184
- const { currentErrors, isCritical } = compileControls();
185
- setErrorActive({ ...errorActive, [pageTag]: currentErrors || {} });
186
- if (currentErrors && Object.keys(currentErrors).length > 0) {
187
- setErrorsForModal({ currentErrors, isCritical });
188
- } else goNextPage();
189
- }, [compileControls, errorActive, goNextPage, pageTag]);
190
-
191
- // Allow PageDown / PageUp shortcut to ease navigation
192
- useEffect(() => {
193
- const listener = (e) => {
194
- let stopPropagation = false;
195
- if (e.key === 'PageDown') {
196
- handleGoNext();
197
- stopPropagation = true;
198
- }
199
- if (e.key === 'PageUp') {
200
- goPreviousPage();
201
- stopPropagation = true;
202
- }
203
- if (stopPropagation) {
204
- e.preventDefault();
205
- e.stopPropagation();
206
- }
207
- };
208
- document.addEventListener('keydown', listener);
209
- return () => {
210
- document.removeEventListener('keydown', listener);
211
- };
212
- }, [handleGoNext, goPreviousPage]);
213
-
214
- return (
215
- <Provider>
216
- <div className="container story-with-sidebar">
217
- <div className="components">
218
- <LunaticComponents
219
- slots={slots}
220
- autoFocusKey={pageTag}
221
- components={components}
222
- componentProps={() => ({
223
- errors: errorActive[pageTag],
224
- disabled: disabled,
225
- readOnly: readOnly,
226
- })}
227
- />
228
- <SchemaValidator source={source} />
229
- </div>
230
- <aside>
231
- <Pager
232
- goPrevious={goPreviousPage}
233
- goNext={handleGoNext}
234
- goToPage={goToPage}
235
- lastReachedPage={lastReachedPage}
236
- isLast={isLastPage}
237
- isFirst={isFirstPage}
238
- pageTag={pageTag}
239
- maxPage={maxPage}
240
- getData={getData}
241
- pager={pager}
242
- />
243
- <div className="story-pager">
244
- <h3>Misc</h3>
245
- <ul>
246
- <li>
247
- <strong>pageHasResponse:</strong>{' '}
248
- {JSON.stringify(hasPageResponse())}
249
- </li>
250
- </ul>
251
- </div>
252
- {showOverview && <Overview overview={overview} goToPage={goToPage} />}
253
- {errorsForModal && (
254
- <ModalControls
255
- errors={errorsForModal.currentErrors}
256
- goNext={skip}
257
- onClose={closeModal}
258
- isCritical={errorsForModal.isCritical}
259
- />
260
- )}
261
- </aside>
262
- </div>
263
- </Provider>
264
- );
265
- }
266
-
267
- export default memo(OrchestratorForStories);
@@ -1,66 +0,0 @@
1
- .dev-options {
2
- background-color: antiquewhite;
3
- padding: 5px 5px;
4
- border: solid burlywood 2px;
5
- display: grid;
6
- grid-template-columns: 1fr;
7
- gap: 1rem;
8
- }
9
-
10
- .story-with-sidebar {
11
- font-family: sans-serif;
12
- display: grid;
13
- height: 100%;
14
- grid-template-columns: 1fr 300px;
15
- align-items: flex-start;
16
- }
17
-
18
- .story-with-sidebar aside label {
19
- display: block;
20
- font-weight: bold;
21
- margin-bottom: 0.3em;
22
- }
23
-
24
- .story-with-sidebar aside {
25
- display: grid;
26
- grid-template-columns: 1fr;
27
- gap: 1rem;
28
- padding: 1rem;
29
- box-shadow:
30
- 0 4px 3px rgba(0, 0, 0, 0.07),
31
- 0px 2px 2px rgba(0, 0, 0, 0.06);
32
- background-color: #f1f5f9;
33
-
34
- .pagination {
35
- margin-top: 0;
36
- }
37
- }
38
-
39
- .story-pager h3 {
40
- font-size: 1rem;
41
- padding-bottom: 0.3rem;
42
- margin-bottom: 0.5rem;
43
- border-bottom: solid 1px rgba(0, 0, 0, 0.3);
44
- }
45
-
46
- .story-pager ul {
47
- margin: 0;
48
- padding: 0 0 0 20px;
49
- line-height: 1.4;
50
- font-size: 0.9rem;
51
- color: rgba(0, 0, 0, 0.75);
52
- }
53
-
54
- .story-pager ul strong {
55
- color: #000;
56
- }
57
-
58
- .json-errors {
59
- color: #721c24;
60
- background-color: #f8d7da;
61
- position: relative;
62
- padding: 0.75rem 1.25rem;
63
- margin-bottom: 1rem;
64
- border: 1px solid #f5c6cb;
65
- border-radius: 0.25rem;
66
- }
@@ -1,39 +0,0 @@
1
- import { Fragment } from 'react';
2
- import './overview.scss';
3
-
4
- export const Overview = ({ overview: stateOverview, goToPage }) => {
5
- return (
6
- <ol className="orchestrator-overview">
7
- {stateOverview.map((entry) => (
8
- <OverviewItem
9
- key={`view-${entry.id}-${entry.page}`}
10
- overviewEntry={entry}
11
- goToPage={goToPage}
12
- />
13
- ))}
14
- </ol>
15
- );
16
- };
17
-
18
- const OverviewItem = ({ overviewEntry, goToPage }) => {
19
- let color = 'grey';
20
- if (overviewEntry.reached) {
21
- color = 'var(--color-primary-main)';
22
- }
23
- if (overviewEntry.current) {
24
- color = 'green';
25
- }
26
- return (
27
- <Fragment>
28
- <li style={{ color: color }}>
29
- <div onClick={() => goToPage({ page: overviewEntry.page })}>
30
- <span>{overviewEntry.label}</span>
31
- <span>({overviewEntry.page})</span>
32
- </div>
33
- {overviewEntry.children.length > 0 && (
34
- <Overview overview={overviewEntry.children} goToPage={goToPage} />
35
- )}
36
- </li>
37
- </Fragment>
38
- );
39
- };
@@ -1,37 +0,0 @@
1
- * {
2
- box-sizing: border-box;
3
- --color-primary-dark: #2a5885;
4
- --color-primary-light: #5181b8;
5
- --color-primary-main: #4a73a4;
6
- --color-primary-contrast-text: #ffffff;
7
-
8
- --color-secondary-dark: #14202d;
9
- --color-secondary-light: #f7f8fa;
10
- --color-secondary-main: #1a293b;
11
- --color-secondary-contrast-text: #ffffff;
12
-
13
- --color-very-light: #dbe4ef;
14
- --color-very-very-light: #e6eaee;
15
- --color-current-item: #0d823e;
16
-
17
- --color-error: #f50c0c;
18
- --color-disabled: rgb(235, 235, 228);
19
- }
20
-
21
- .orchestrator-overview {
22
- margin: 0;
23
- padding: 0;
24
-
25
- div {
26
- display: flex;
27
- justify-content: space-between;
28
- }
29
-
30
- ol {
31
- margin-left: 2rem;
32
- }
33
-
34
- li {
35
- list-style: none;
36
- }
37
- }
@@ -1,7 +0,0 @@
1
- export const getReferentiel = async (name) => {
2
- try {
3
- return fetch(`./${name}.json`).then((r) => r.json());
4
- } catch (error) {
5
- throw new Error(`Unknown référentiel ${name}`);
6
- }
7
- }
@@ -1,91 +0,0 @@
1
- import { userEvent, waitFor, within, expect } from '@storybook/test';
2
- import { sleep } from './timer';
3
-
4
- /**
5
- * Bridge between playwright tests and storybook tests
6
- * This is used to have a similar API for both tests
7
- */
8
- export function playwrightToUserEvent(canvas) {
9
- return new Page(canvas);
10
- }
11
-
12
- class Page {
13
- /**
14
- * @param {HTMLElement} canvas
15
- */
16
- constructor(canvas) {
17
- this.canvas = within(canvas);
18
- }
19
-
20
- getByRole(...args) {
21
- return new Instruction(this.canvas.findByRole(...args));
22
- }
23
-
24
- getByText(...args) {
25
- if (args[1] && args[1].index !== undefined) {
26
- const index = args[1].index;
27
- return new Instruction(
28
- this.canvas.findAllByText(...args).then((r) => r[index])
29
- );
30
- }
31
- return new Instruction(this.canvas.findByText(...args));
32
- }
33
-
34
- getByLabel(...args) {
35
- if (args[1] && args[1].index !== undefined) {
36
- const index = args[1].index;
37
- return new Instruction(
38
- this.canvas.findAllByLabelText(...args).then((r) => r[index])
39
- );
40
- }
41
- return new Instruction(this.canvas.findByLabelText(...args));
42
- }
43
-
44
- async keyPress(char) {
45
- return userEvent.keyboard(char);
46
- }
47
- }
48
-
49
- class Instruction {
50
- constructor(element) {
51
- if (element instanceof Error) {
52
- throw element;
53
- }
54
- this.element = element;
55
- }
56
-
57
- async shouldBeVisible() {
58
- return waitFor(async () => expect(await this.element).toBeVisible());
59
- }
60
-
61
- locator(selector) {
62
- return new Instruction(this.element.then((b) => b.querySelector(selector)));
63
- }
64
-
65
- getByRole(...args) {
66
- return new Instruction(
67
- this.element.then((b) => within(b).findByRole(...args))
68
- );
69
- }
70
-
71
- getByText(...args) {
72
- return new Instruction(
73
- this.element.then((b) => within(b).findByText(...args))
74
- );
75
- }
76
-
77
- async click() {
78
- return userEvent.click(await this.element);
79
- }
80
-
81
- async fill(text) {
82
- const element = await this.element;
83
- try {
84
- await userEvent.clear(element);
85
- await sleep(1);
86
- } catch (e) {
87
- // Do nothing
88
- }
89
- return userEvent.type(element, text, { delay: 1 });
90
- }
91
- }
@@ -1,33 +0,0 @@
1
- import type { LunaticData } from '../../use-lunatic/type';
2
-
3
- /**
4
- * Generate LunaticData from a record of values
5
- */
6
- export function generateData<T extends Record<string, unknown>>(
7
- data: T
8
- ): LunaticData {
9
- return {
10
- COLLECTED: Object.fromEntries(
11
- Object.entries(data).map(([key, value]) => [
12
- key,
13
- {
14
- CALCULATED: null,
15
- EXTERNAL: null,
16
- COLLECTED: value,
17
- },
18
- ])
19
- ) as Record<string, any>,
20
- CALCULATED: {},
21
- EXTERNAL: {},
22
- };
23
- }
24
-
25
- export function generateVariable({ type = 'COLLECTED', name = 'VARIABLE' }) {
26
- return {
27
- variableType: type,
28
- name: name,
29
- values: {
30
- COLLECTED: null,
31
- },
32
- };
33
- }
@@ -1,25 +0,0 @@
1
- import type { LunaticComponentDefinition } from './type';
2
-
3
- /**
4
- * Pour le Question : les composants du fieldset n'existe pas dans pages.
5
- * Ils échappent donc aux controls. On les substitue ici au Question.
6
- * On ne peut pas les ajouter directement dans pages (en spécifiant un page), car ils s'afficheraient 2 fois : dans le fieldset et en dessus, comme
7
- * des composant à part entière.
8
- * D'autres composant pourraient un jour figurer ici.
9
- */
10
- export function replaceComponentSequence(
11
- components: Array<LunaticComponentDefinition>
12
- ) {
13
- return components.reduce(function (
14
- acc: Array<LunaticComponentDefinition>,
15
- component
16
- ) {
17
- const { componentType } = component;
18
- switch (componentType) {
19
- case 'Question':
20
- return [...acc, ...component.components];
21
- default:
22
- return [...acc, component];
23
- }
24
- }, []);
25
- }
@@ -1,17 +0,0 @@
1
- import { LunaticData } from './type';
2
-
3
- export const dataFromObject = (o: Record<string, unknown>): LunaticData => {
4
- return {
5
- EXTERNAL: {},
6
- COLLECTED: Object.keys(o).reduce(
7
- (acc, k) => ({
8
- ...acc,
9
- [k]: {
10
- COLLECTED: o[k],
11
- },
12
- }),
13
- {}
14
- ),
15
- CALCULATED: {},
16
- };
17
- };
@@ -1,6 +0,0 @@
1
- /**
2
- * isObject function with type narrowing
3
- */
4
- export function isObject(v: unknown): v is Record<string, unknown> {
5
- return typeof v === 'object' && v !== null;
6
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * Convert an unknown value into a number
3
- */
4
- export function toNumber(v: unknown): number | null {
5
- if (typeof v === 'number') {
6
- return v;
7
- }
8
- if (typeof v === 'string') {
9
- return parseInt(v, 10);
10
- }
11
- return null;
12
- }