@inseefr/lunatic 3.6.15-rc.0 → 3.6.15-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.
- package/components/Roundabout/Roundabout.js +8 -3
- package/components/Roundabout/Roundabout.js.map +1 -1
- package/esm/components/Roundabout/Roundabout.js +8 -3
- package/esm/components/Roundabout/Roundabout.js.map +1 -1
- package/esm/hooks/{useMultiMode.d.ts → useMultimode.d.ts} +2 -2
- package/esm/hooks/{useMultiMode.js → useMultimode.js} +5 -5
- package/esm/hooks/{useMultiMode.js.map → useMultimode.js.map} +1 -1
- package/esm/index.d.ts +1 -1
- package/esm/index.js +1 -1
- package/esm/index.js.map +1 -1
- package/esm/type.source.d.ts +2 -24
- package/esm/type.source.js +0 -1
- package/esm/type.source.js.map +1 -1
- package/esm/use-lunatic/reducer/reduce-go-next-page.js +2 -1
- package/esm/use-lunatic/reducer/reduce-go-next-page.js.map +1 -1
- package/esm/use-lunatic/type.d.ts +1 -1
- package/esm/use-lunatic/use-lunatic.js +3 -3
- package/{utils/getArticulation.d.ts → esm/utils/getArticulationState.d.ts} +8 -5
- package/esm/utils/{getArticulation.js → getArticulationState.js} +10 -6
- package/esm/utils/getArticulationState.js.map +1 -0
- package/hooks/{useMultiMode.d.ts → useMultimode.d.ts} +2 -2
- package/hooks/{useMultiMode.js → useMultimode.js} +7 -7
- package/hooks/{useMultiMode.js.map → useMultimode.js.map} +1 -1
- package/index.d.ts +1 -1
- package/index.js +3 -3
- package/index.js.map +1 -1
- package/package.json +15 -15
- package/src/components/Roundabout/Roundabout.tsx +8 -3
- package/src/hooks/{useMultiMode.ts → useMultimode.ts} +4 -4
- package/src/index.ts +1 -1
- package/src/stories/behaviour/articulation/articulation.stories.tsx +4 -4
- package/src/stories/utils/Orchestrator.tsx +2 -2
- package/src/stories/utils/OrchestratorSidebar.tsx +7 -7
- package/src/type.source.ts +2 -25
- package/src/use-lunatic/reducer/reduce-go-next-page.ts +2 -1
- package/src/use-lunatic/type.ts +1 -1
- package/src/use-lunatic/use-lunatic.ts +3 -3
- package/src/utils/{getArticulation.ts → getArticulationState.ts} +13 -6
- package/tsconfig.build.tsbuildinfo +1 -1
- package/type.source.d.ts +2 -24
- package/type.source.js +0 -1
- package/type.source.js.map +1 -1
- package/use-lunatic/reducer/reduce-go-next-page.js +2 -1
- package/use-lunatic/reducer/reduce-go-next-page.js.map +1 -1
- package/use-lunatic/type.d.ts +1 -1
- package/use-lunatic/use-lunatic.js +3 -3
- package/{esm/utils/getArticulation.d.ts → utils/getArticulationState.d.ts} +8 -5
- package/utils/{getArticulation.js → getArticulationState.js} +13 -7
- package/utils/getArticulationState.js.map +1 -0
- package/esm/utils/getArticulation.js.map +0 -1
- package/utils/getArticulation.js.map +0 -1
|
@@ -98,7 +98,7 @@ function OrchestratorForStories(props: Readonly<Props>) {
|
|
|
98
98
|
getData,
|
|
99
99
|
Provider,
|
|
100
100
|
hasPageResponse,
|
|
101
|
-
|
|
101
|
+
getMultimode,
|
|
102
102
|
} = useLunatic(source, data, {
|
|
103
103
|
initialPage,
|
|
104
104
|
disableFilters,
|
|
@@ -249,7 +249,7 @@ function OrchestratorForStories(props: Readonly<Props>) {
|
|
|
249
249
|
pageTag={pageTag}
|
|
250
250
|
pager={pager}
|
|
251
251
|
hasPageResponse={hasPageResponse()}
|
|
252
|
-
|
|
252
|
+
getMultimode={props.multiMode ? getMultimode : null}
|
|
253
253
|
onLogData={() => console.log('Data', getData(true))}
|
|
254
254
|
onLogComponents={() => console.log('Components', components)}
|
|
255
255
|
>
|
|
@@ -17,7 +17,7 @@ type Props = PropsWithChildren<
|
|
|
17
17
|
> & {
|
|
18
18
|
hasPageResponse: unknown;
|
|
19
19
|
onLogData: () => void;
|
|
20
|
-
|
|
20
|
+
getMultimode: LunaticState['getMultimode'] | null;
|
|
21
21
|
onLogComponents: () => void;
|
|
22
22
|
};
|
|
23
23
|
|
|
@@ -30,7 +30,7 @@ export function OrchestratorSidebar({
|
|
|
30
30
|
pageTag,
|
|
31
31
|
pager,
|
|
32
32
|
children,
|
|
33
|
-
|
|
33
|
+
getMultimode,
|
|
34
34
|
hasPageResponse,
|
|
35
35
|
onLogData,
|
|
36
36
|
onLogComponents,
|
|
@@ -116,9 +116,9 @@ export function OrchestratorSidebar({
|
|
|
116
116
|
</li>
|
|
117
117
|
</ul>
|
|
118
118
|
</div>
|
|
119
|
-
{
|
|
119
|
+
{getMultimode && (
|
|
120
120
|
<div>
|
|
121
|
-
<MultiMode
|
|
121
|
+
<MultiMode getMultimode={getMultimode} />
|
|
122
122
|
</div>
|
|
123
123
|
)}
|
|
124
124
|
{children}
|
|
@@ -126,10 +126,10 @@ export function OrchestratorSidebar({
|
|
|
126
126
|
);
|
|
127
127
|
}
|
|
128
128
|
|
|
129
|
-
function MultiMode(props: Pick<LunaticState, '
|
|
130
|
-
const [state, setState] = useState<ReturnType<typeof props.
|
|
129
|
+
function MultiMode(props: Pick<LunaticState, 'getMultimode'>) {
|
|
130
|
+
const [state, setState] = useState<ReturnType<typeof props.getMultimode>>({});
|
|
131
131
|
const onClick = () => {
|
|
132
|
-
setState(props.
|
|
132
|
+
setState(props.getMultimode);
|
|
133
133
|
};
|
|
134
134
|
return (
|
|
135
135
|
<div className="space-y-2">
|
package/src/type.source.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/* eslint-disable */
|
|
2
1
|
/**
|
|
3
2
|
* This file was automatically generated by json-schema-to-typescript.
|
|
4
3
|
* DO NOT MODIFY IT BY HAND. Instead, modify the source JSONSchema file,
|
|
@@ -351,13 +350,13 @@ export type LunaticSource = {
|
|
|
351
350
|
multimode?: {
|
|
352
351
|
questionnaire: {
|
|
353
352
|
rules: {
|
|
354
|
-
[k: string]:
|
|
353
|
+
[k: string]: VTLExpression;
|
|
355
354
|
};
|
|
356
355
|
};
|
|
357
356
|
leaf: {
|
|
358
357
|
source: string;
|
|
359
358
|
rules: {
|
|
360
|
-
[k: string]:
|
|
359
|
+
[k: string]: VTLExpression;
|
|
361
360
|
};
|
|
362
361
|
};
|
|
363
362
|
};
|
|
@@ -501,25 +500,3 @@ export type SuggesterDefinition = {
|
|
|
501
500
|
*/
|
|
502
501
|
stopWords?: string[];
|
|
503
502
|
};
|
|
504
|
-
export type VTLExpression1 = {
|
|
505
|
-
/**
|
|
506
|
-
* Valid VTL Expression
|
|
507
|
-
*/
|
|
508
|
-
value: string;
|
|
509
|
-
/**
|
|
510
|
-
* Variables used in the expression
|
|
511
|
-
*/
|
|
512
|
-
bindingDependencies?: string[];
|
|
513
|
-
type: 'VTL' | 'VTL|MD' | 'TXT';
|
|
514
|
-
};
|
|
515
|
-
export type VTLExpression2 = {
|
|
516
|
-
/**
|
|
517
|
-
* Valid VTL Expression
|
|
518
|
-
*/
|
|
519
|
-
value: string;
|
|
520
|
-
/**
|
|
521
|
-
* Variables used in the expression
|
|
522
|
-
*/
|
|
523
|
-
bindingDependencies?: string[];
|
|
524
|
-
type: 'VTL' | 'VTL|MD' | 'TXT';
|
|
525
|
-
};
|
|
@@ -5,6 +5,7 @@ import type { LunaticReducerState } from '../type';
|
|
|
5
5
|
import { autoExploreLoop } from './commons/auto-explore-loop';
|
|
6
6
|
import { reduceHandleChanges } from './reduce-handle-changes';
|
|
7
7
|
import { ActionKind } from '../actions';
|
|
8
|
+
import { ArticulationState } from '../../utils/getArticulationState';
|
|
8
9
|
|
|
9
10
|
export function reduceGoNextPage(
|
|
10
11
|
state: LunaticReducerState
|
|
@@ -51,7 +52,7 @@ export function reduceGoNextPage(
|
|
|
51
52
|
responses: [
|
|
52
53
|
{
|
|
53
54
|
name: firstComponent.progressVariable,
|
|
54
|
-
value:
|
|
55
|
+
value: ArticulationState.COMPLETED,
|
|
55
56
|
iteration: [newState.previousPager.iteration],
|
|
56
57
|
},
|
|
57
58
|
],
|
package/src/use-lunatic/type.ts
CHANGED
|
@@ -359,7 +359,7 @@ export type LunaticState = {
|
|
|
359
359
|
*/
|
|
360
360
|
handleChanges: LunaticChangesHandler;
|
|
361
361
|
/** Return the multimode state **/
|
|
362
|
-
|
|
362
|
+
getMultimode: () => Record<string, boolean>;
|
|
363
363
|
};
|
|
364
364
|
|
|
365
365
|
/** Function taking as arguments the various changes the user has made. */
|
|
@@ -33,7 +33,7 @@ import { useRefSync } from '../hooks/useRefSync';
|
|
|
33
33
|
import { ConsoleLogger } from './logger/ConsoleLogger';
|
|
34
34
|
import { useWarnDepChange } from './hooks/useWarnDepChange';
|
|
35
35
|
import { useCallbackOnNextRender } from './hooks/useCallbackOnNextRender';
|
|
36
|
-
import {
|
|
36
|
+
import { useMultimode } from '../hooks/useMultimode';
|
|
37
37
|
|
|
38
38
|
const empty = {}; // Keep the same empty object (to avoid problem with useEffect dependencies)
|
|
39
39
|
const DEFAULT_DATA = empty as LunaticData;
|
|
@@ -199,7 +199,7 @@ export function useLunatic(
|
|
|
199
199
|
(variableNames?: string[]) => getData(false, variableNames)
|
|
200
200
|
);
|
|
201
201
|
|
|
202
|
-
const {
|
|
202
|
+
const { getMultimode } = useMultimode(source, state.variables);
|
|
203
203
|
|
|
204
204
|
const pageTag = getPageTag(state.pager);
|
|
205
205
|
const { isFirstPage, isLastPage } = isFirstLastPage(state.pager);
|
|
@@ -244,6 +244,6 @@ export function useLunatic(
|
|
|
244
244
|
// Components
|
|
245
245
|
Provider,
|
|
246
246
|
handleChanges,
|
|
247
|
-
|
|
247
|
+
getMultimode,
|
|
248
248
|
} satisfies LunaticState;
|
|
249
249
|
}
|
|
@@ -9,6 +9,12 @@ import { type ReactNode } from 'react';
|
|
|
9
9
|
import { times } from './array';
|
|
10
10
|
import { forceInt } from './number';
|
|
11
11
|
|
|
12
|
+
export enum ArticulationState {
|
|
13
|
+
COMPLETED = 1,
|
|
14
|
+
STARTED = 0,
|
|
15
|
+
NOT_STARTED = -1,
|
|
16
|
+
}
|
|
17
|
+
|
|
12
18
|
type ArticulationItem = {
|
|
13
19
|
label: string;
|
|
14
20
|
value: string;
|
|
@@ -24,16 +30,14 @@ type Item = {
|
|
|
24
30
|
label: string;
|
|
25
31
|
value: ReactNode;
|
|
26
32
|
}[];
|
|
27
|
-
progress:
|
|
33
|
+
progress: ArticulationState; // -1: not completed, 0: started, 1: finished
|
|
28
34
|
page: PageTag;
|
|
29
35
|
};
|
|
30
36
|
|
|
31
37
|
/**
|
|
32
38
|
* Retrieve the articulation state
|
|
33
39
|
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
36
|
-
* The goal of this hook is to provide insights about a roundabout using extra information inserted in the JSON source
|
|
40
|
+
* The goal of this function is to provide insights about a roundabout using extra information inserted in the JSON source
|
|
37
41
|
* provided to Lunatic.
|
|
38
42
|
*
|
|
39
43
|
* For instance
|
|
@@ -61,7 +65,7 @@ type Item = {
|
|
|
61
65
|
* - source is the ID of the roundabout component
|
|
62
66
|
* - items define the field to extract from the roundabout data
|
|
63
67
|
*/
|
|
64
|
-
export function
|
|
68
|
+
export function getArticulationState(
|
|
65
69
|
source: LunaticSource & { articulation: Articulation },
|
|
66
70
|
data: LunaticData
|
|
67
71
|
): { items: Item[] } {
|
|
@@ -90,7 +94,10 @@ export function getArticulation(
|
|
|
90
94
|
return {
|
|
91
95
|
items: rows.map((row, k) => ({
|
|
92
96
|
cells: row,
|
|
93
|
-
progress: forceInt(
|
|
97
|
+
progress: forceInt(
|
|
98
|
+
variables.get(roundabout.progressVariable, [k]) ??
|
|
99
|
+
ArticulationState.NOT_STARTED
|
|
100
|
+
),
|
|
94
101
|
page: (roundabout.page
|
|
95
102
|
? `${roundabout.page}.1#${k + 1}`
|
|
96
103
|
: '1') as PageTag,
|