@inseefr/lunatic 3.5.7 → 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.
- package/components/shared/Combobox/Combobox.stories.d.ts +3 -2
- package/components/shared/Combobox/Combobox.stories.js +26 -21
- package/components/shared/Combobox/Combobox.stories.js.map +1 -1
- package/esm/components/shared/Combobox/Combobox.stories.d.ts +3 -2
- package/esm/components/shared/Combobox/Combobox.stories.js +28 -24
- package/esm/components/shared/Combobox/Combobox.stories.js.map +1 -1
- package/esm/hooks/useLocalStorage.d.ts +1 -0
- package/esm/hooks/useLocalStorage.js +31 -0
- package/esm/hooks/useLocalStorage.js.map +1 -0
- package/esm/type.source.d.ts +6 -0
- package/esm/use-lunatic/commons/compile-controls.js +22 -14
- package/esm/use-lunatic/commons/compile-controls.js.map +1 -1
- package/esm/use-lunatic/commons/fill-components/fill-component-expressions.js +4 -1
- package/esm/use-lunatic/commons/fill-components/fill-component-expressions.js.map +1 -1
- package/esm/use-lunatic/hooks/use-page-has-response.js +1 -1
- package/esm/use-lunatic/hooks/use-page-has-response.js.map +1 -1
- package/esm/use-lunatic/hooks/useOverview.spec.js +2 -2
- package/esm/use-lunatic/hooks/useOverview.spec.js.map +1 -1
- package/esm/utils/number.d.ts +4 -0
- package/esm/utils/number.js +12 -0
- package/esm/utils/number.js.map +1 -1
- package/esm/utils/object.d.ts +10 -0
- package/esm/utils/object.js +26 -0
- package/esm/utils/object.js.map +1 -1
- package/hooks/useLocalStorage.d.ts +1 -0
- package/hooks/useLocalStorage.js +34 -0
- package/hooks/useLocalStorage.js.map +1 -0
- package/package.json +76 -137
- package/src/components/shared/Combobox/Combobox.stories.tsx +48 -49
- package/src/hooks/useLocalStorage.ts +37 -0
- package/src/json.d.ts +16 -0
- package/src/stories/accordion/accordion.stories.tsx +21 -0
- package/src/stories/behaviour/cleaning/cleaning.stories.tsx +40 -0
- package/src/stories/behaviour/controls/controls.stories.tsx +51 -0
- package/src/stories/behaviour/disabled/disabled.stories.tsx +29 -0
- package/src/stories/behaviour/filter/filter.stories.tsx +34 -0
- package/src/stories/behaviour/missing/missing.stories.tsx +31 -0
- package/src/stories/behaviour/overview/overview.stories.tsx +61 -0
- package/src/stories/{overview/sourceWithHierarchy.json → behaviour/overview/source.json} +1 -1
- package/src/stories/{overview → behaviour/overview}/sourceLoop.json +1 -1
- package/src/stories/behaviour/performance/performance.stories.tsx +29 -0
- package/src/stories/behaviour/resizing/resizing.stories.tsx +34 -0
- package/src/stories/behaviour/slots.stories.tsx +34 -0
- package/src/stories/checkbox/checkbox.stories.tsx +75 -0
- package/src/stories/{checkbox-group/sourceLoop.json → checkbox/sourceGroupLoop.json} +1 -1
- package/src/stories/datepicker/datepicker.stories.tsx +21 -0
- package/src/stories/declaration/declaration.stories.tsx +27 -0
- package/src/stories/dropdown/dropdown.stories.tsx +27 -0
- package/src/stories/duration/duration.stories.tsx +27 -0
- package/src/stories/filter-description/filter-description.stories.tsx +28 -0
- package/src/stories/input/input.stories.tsx +21 -0
- package/src/stories/input-number/input-number.stories.tsx +35 -0
- package/src/stories/loop/loop.stories.tsx +35 -0
- package/src/stories/loop/roster-for-loop.stories.tsx +59 -0
- package/src/stories/pairwise/pairwise.stories.tsx +30 -0
- package/src/stories/paste.stories.tsx +85 -0
- package/src/stories/question/question.stories.tsx +21 -0
- package/src/stories/questionnaires/logement/logement.stories.tsx +26 -0
- package/src/stories/questionnaires/recensement/recensement.stories.tsx +28 -0
- package/src/stories/questionnaires/rp/rp.stories.tsx +21 -0
- package/src/stories/questionnaires/simpsons/simpsons.stories.tsx +31 -0
- package/src/stories/radio/radio.stories.tsx +53 -0
- package/src/stories/roundabout/roundabout.stories.tsx +37 -0
- package/src/stories/roundabout/source.json +1 -0
- package/src/stories/sequence/sequence.stories.tsx +28 -0
- package/src/stories/suggester/source-option-responses.json +1 -1
- package/src/stories/suggester/suggester.stories.tsx +68 -0
- package/src/stories/summary/source.json +22 -1
- package/src/stories/summary/summary.stories.tsx +31 -0
- package/src/stories/table/table.stories.tsx +35 -0
- package/src/stories/text/text.stories.tsx +38 -0
- package/src/stories/textarea/textarea.stories.tsx +21 -0
- package/src/stories/utils/Orchestrator.tsx +310 -0
- package/src/stories/utils/OrchestratorData.tsx +176 -0
- package/src/stories/utils/OrchestratorOverview.tsx +70 -0
- package/src/stories/utils/OrchestratorSidebar.tsx +119 -0
- package/src/stories/utils/SchemaValidator.tsx +29 -0
- package/src/stories/utils/referentiel.ts +9 -0
- package/src/type.source.ts +6 -0
- package/src/use-lunatic/commons/compile-controls.ts +36 -18
- package/src/use-lunatic/commons/fill-components/fill-component-expressions.ts +4 -1
- package/src/use-lunatic/hooks/use-page-has-response.ts +1 -1
- package/src/use-lunatic/hooks/useOverview.spec.ts +3 -2
- package/src/use-lunatic/use-lunatic.test.ts +53 -40
- package/src/utils/number.ts +13 -0
- package/src/utils/object.ts +40 -0
- package/tsconfig.build.tsbuildinfo +1 -1
- package/type.source.d.ts +6 -0
- package/use-lunatic/commons/compile-controls.js +21 -13
- package/use-lunatic/commons/compile-controls.js.map +1 -1
- package/use-lunatic/commons/fill-components/fill-component-expressions.js +5 -2
- package/use-lunatic/commons/fill-components/fill-component-expressions.js.map +1 -1
- package/use-lunatic/hooks/use-page-has-response.js +2 -2
- package/use-lunatic/hooks/use-page-has-response.js.map +1 -1
- package/use-lunatic/hooks/useOverview.spec.js +8 -8
- package/use-lunatic/hooks/useOverview.spec.js.map +1 -1
- package/utils/number.d.ts +4 -0
- package/utils/number.js +13 -0
- package/utils/number.js.map +1 -1
- package/utils/object.d.ts +10 -0
- package/utils/object.js +30 -0
- package/utils/object.js.map +1 -1
- package/esm/stories/overview/sourceWithHierarchy.json +0 -5151
- package/esm/tests/utils/lunatic.d.ts +0 -15
- package/esm/tests/utils/lunatic.js +0 -27
- package/esm/tests/utils/lunatic.js.map +0 -1
- package/esm/use-lunatic/replace-component-sequence.d.ts +0 -36
- package/esm/use-lunatic/replace-component-sequence.js +0 -19
- package/esm/use-lunatic/replace-component-sequence.js.map +0 -1
- package/esm/use-lunatic/test.utils.d.ts +0 -2
- package/esm/use-lunatic/test.utils.js +0 -13
- package/esm/use-lunatic/test.utils.js.map +0 -1
- package/esm/utils/is-object.d.ts +0 -4
- package/esm/utils/is-object.js +0 -7
- package/esm/utils/is-object.js.map +0 -1
- package/esm/utils/to-number.d.ts +0 -4
- package/esm/utils/to-number.js +0 -13
- package/esm/utils/to-number.js.map +0 -1
- package/src/stories/accordion/accordion.stories.jsx +0 -17
- package/src/stories/behaviour/cleaning/cleaning.stories.jsx +0 -69
- package/src/stories/behaviour/controls/controls.stories.jsx +0 -81
- package/src/stories/behaviour/filter/dataLoop.json +0 -14
- package/src/stories/behaviour/filter/filter.stories.jsx +0 -36
- package/src/stories/behaviour/missing/missing.stories.jsx +0 -69
- package/src/stories/behaviour/others/V2_DeclarationsSimples.json +0 -908
- package/src/stories/behaviour/others/V2_MinMaxSum_Boucles.json +0 -489
- package/src/stories/behaviour/others/V2_QuestSimple_Boucles.json +0 -3919
- package/src/stories/behaviour/others/V2_TCMRallyeGames.json +0 -2760
- package/src/stories/behaviour/others/test-dylan.json +0 -538
- package/src/stories/behaviour/others/test.stories.jsx +0 -78
- package/src/stories/behaviour/paste/source.json +0 -32
- package/src/stories/behaviour/paste/test.stories.jsx +0 -62
- package/src/stories/behaviour/performance/performance.stories.jsx +0 -26
- package/src/stories/behaviour/resizing/resizing.stories.jsx +0 -60
- package/src/stories/behaviour/slots.stories.jsx +0 -32
- package/src/stories/checkbox-boolean/checkboxBoolean.stories.jsx +0 -17
- package/src/stories/checkbox-group/checkbox-group.stories.jsx +0 -77
- package/src/stories/checkbox-one/checkboxOne.stories.jsx +0 -53
- package/src/stories/date-picker/data.json +0 -3
- package/src/stories/date-picker/datepicker.stories.jsx +0 -26
- package/src/stories/declaration/data.json +0 -1
- package/src/stories/declaration/input.stories.jsx +0 -18
- package/src/stories/disabled/data.json +0 -16
- package/src/stories/disabled/disabled.stories.jsx +0 -18
- package/src/stories/dropdown/data.json +0 -8
- package/src/stories/dropdown/dropdown.stories.jsx +0 -25
- package/src/stories/duration/duration.stories.jsx +0 -25
- package/src/stories/filter-description/filter-description.stories.jsx +0 -37
- package/src/stories/input/data.json +0 -1
- package/src/stories/input/input.stories.jsx +0 -18
- package/src/stories/input-number/input-number.stories.jsx +0 -23
- package/src/stories/loop/loop.stories.jsx +0 -29
- package/src/stories/loop/roster-for-loop.stories.jsx +0 -46
- package/src/stories/markdown/markdown.stories.jsx +0 -20
- package/src/stories/overview/data.json +0 -1
- package/src/stories/overview/dataLoop.json +0 -93
- package/src/stories/overview/overview.stories.jsx +0 -44
- package/src/stories/overview/source.json +0 -25
- package/src/stories/pairwise/data.json +0 -12
- package/src/stories/pairwise/pairwise-links.stories.jsx +0 -48
- package/src/stories/question/question.stories.jsx +0 -16
- package/src/stories/questionnaires/logement/logement.stories.jsx +0 -59
- package/src/stories/questionnaires/recensement/data.json +0 -12
- package/src/stories/questionnaires/recensement/recensement.stories.jsx +0 -35
- package/src/stories/questionnaires/rp/data.json +0 -5
- package/src/stories/questionnaires/rp/rp.stories.jsx +0 -23
- package/src/stories/questionnaires/simpsons/simpsons.stories.jsx +0 -246
- package/src/stories/radio/radio.stories.jsx +0 -78
- package/src/stories/roundabout/data1.json +0 -13
- package/src/stories/roundabout/data2.json +0 -16
- package/src/stories/roundabout/roundabout.stories.jsx +0 -32
- package/src/stories/sequence/sequence.stories.jsx +0 -29
- package/src/stories/suggester/suggester.stories.jsx +0 -71
- package/src/stories/summary/data.json +0 -16
- package/src/stories/summary/summary.stories.jsx +0 -23
- package/src/stories/switch/README.md +0 -29
- package/src/stories/switch/data-forced.json +0 -40
- package/src/stories/switch/source.json +0 -64
- package/src/stories/switch/switch.stories.jsx +0 -17
- package/src/stories/table/data.json +0 -1
- package/src/stories/table/table.stories.jsx +0 -30
- package/src/stories/text/data-roster.json +0 -5
- package/src/stories/text/text.stories.jsx +0 -20
- package/src/stories/textarea/data.json +0 -1
- package/src/stories/textarea/textarea.stories.jsx +0 -18
- package/src/stories/utils/SchemaValidator.jsx +0 -40
- package/src/stories/utils/default-arg-types.js +0 -39
- package/src/stories/utils/default-args.js +0 -3
- package/src/stories/utils/options.js +0 -19
- package/src/stories/utils/orchestrator.jsx +0 -267
- package/src/stories/utils/orchestrator.scss +0 -66
- package/src/stories/utils/overview.jsx +0 -39
- package/src/stories/utils/overview.scss +0 -37
- package/src/stories/utils/referentiel.js +0 -7
- package/src/tests/utils/e2e.js +0 -91
- package/src/tests/utils/lunatic.ts +0 -33
- package/src/use-lunatic/replace-component-sequence.ts +0 -25
- package/src/use-lunatic/test.utils.ts +0 -17
- package/src/utils/is-object.ts +0 -6
- package/src/utils/to-number.ts +0 -12
- package/stories/overview/sourceWithHierarchy.json +0 -5151
- package/tests/utils/lunatic.d.ts +0 -15
- package/tests/utils/lunatic.js +0 -31
- package/tests/utils/lunatic.js.map +0 -1
- package/use-lunatic/replace-component-sequence.d.ts +0 -36
- package/use-lunatic/replace-component-sequence.js +0 -22
- package/use-lunatic/replace-component-sequence.js.map +0 -1
- package/use-lunatic/test.utils.d.ts +0 -2
- package/use-lunatic/test.utils.js +0 -17
- package/use-lunatic/test.utils.js.map +0 -1
- package/utils/is-object.d.ts +0 -4
- package/utils/is-object.js +0 -10
- package/utils/is-object.js.map +0 -1
- package/utils/to-number.d.ts +0 -4
- package/utils/to-number.js +0 -16
- package/utils/to-number.js.map +0 -1
- /package/src/stories/behaviour/cleaning/{loop.json → source-loop-scopes.json} +0 -0
- /package/src/stories/behaviour/controls/{boucles-n.json → source-boucles-n.json} +0 -0
- /package/src/stories/behaviour/controls/{loop.json → source-loop.json} +0 -0
- /package/src/stories/behaviour/controls/{roundabout.json → source-roundabout.json} +0 -0
- /package/src/stories/behaviour/controls/{simple-numeric.json → source-simple-numeric.json} +0 -0
- /package/src/stories/behaviour/controls/{simple.json → source-simple.json} +0 -0
- /package/src/stories/{disabled → behaviour/disabled}/source.json +0 -0
- /package/src/stories/{checkbox-boolean → checkbox}/source.json +0 -0
- /package/src/stories/{checkbox-group/source.json → checkbox/sourceGroup.json} +0 -0
- /package/src/stories/{checkbox-group/sourceCondition.json → checkbox/sourceGroupCondition.json} +0 -0
- /package/src/stories/{checkbox-group/sourceDetail.json → checkbox/sourceGroupDetail.json} +0 -0
- /package/src/stories/{checkbox-one/source.json → checkbox/sourceOne.json} +0 -0
- /package/src/stories/{checkbox-one/sourceDetail.json → checkbox/sourceOneDetail.json} +0 -0
- /package/src/stories/{date-picker → datepicker}/source.json +0 -0
- /package/src/stories/{markdown/source.json → declaration/sourceMarkdown.json} +0 -0
- /package/src/stories/duration/{mois.json → sourceMonths.json} +0 -0
- /package/src/stories/duration/{time.json → sourceTime.json} +0 -0
- /package/src/stories/filter-description/{source-options.json → sourceOptions.json} +0 -0
- /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
|
-
}
|
package/src/tests/utils/e2e.js
DELETED
|
@@ -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
|
-
};
|
package/src/utils/is-object.ts
DELETED
package/src/utils/to-number.ts
DELETED