@inseefr/lunatic 3.0.0-rc.26 → 3.0.0-rc.27
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/lib/components/LunaticComponents.d.ts +7 -11
- package/lib/components/LunaticComponents.js +4 -1
- package/lib/components/LunaticComponents.js.map +1 -1
- package/lib/components/Table/Table.js.map +1 -1
- package/lib/components/library.d.ts +1 -1
- package/lib/components/shared/HOC/slottableComponent.d.ts +2 -2
- package/lib/components/shared/MDLabel/MDLabel.js +4 -1
- package/lib/components/shared/MDLabel/MDLabel.js.map +1 -1
- package/lib/components/shared/MDLabel/MDLabel.spec.js +4 -1
- package/lib/components/shared/MDLabel/MDLabel.spec.js.map +1 -1
- package/lib/components/type.d.ts +10 -10
- package/lib/index.d.ts +1 -1
- package/lib/use-lunatic/actions.d.ts +3 -52
- package/lib/use-lunatic/actions.js +0 -7
- package/lib/use-lunatic/actions.js.map +1 -1
- package/lib/use-lunatic/commons/check-loops.d.ts +2 -2
- package/lib/use-lunatic/commons/check-loops.js.map +1 -1
- package/lib/use-lunatic/commons/compile-controls.d.ts +2 -2
- package/lib/use-lunatic/commons/compile-controls.js +5 -3
- package/lib/use-lunatic/commons/compile-controls.js.map +1 -1
- package/lib/use-lunatic/commons/create-map-pages.d.ts +2 -2
- package/lib/use-lunatic/commons/create-map-pages.js.map +1 -1
- package/lib/use-lunatic/commons/execute-condition-filter.d.ts +2 -2
- package/lib/use-lunatic/commons/execute-condition-filter.js +3 -4
- package/lib/use-lunatic/commons/execute-condition-filter.js.map +1 -1
- package/lib/use-lunatic/commons/fill-components/fill-component-expressions.d.ts +614 -6
- package/lib/use-lunatic/commons/fill-components/fill-component-expressions.js +6 -13
- package/lib/use-lunatic/commons/fill-components/fill-component-expressions.js.map +1 -1
- package/lib/use-lunatic/commons/fill-components/fill-component-expressions.spec.js +1 -1
- package/lib/use-lunatic/commons/fill-components/fill-component-expressions.spec.js.map +1 -1
- package/lib/use-lunatic/commons/fill-components/fill-components.d.ts +19 -17
- package/lib/use-lunatic/commons/fill-components/fill-components.js +29 -29
- package/lib/use-lunatic/commons/fill-components/fill-components.js.map +1 -1
- package/lib/use-lunatic/commons/get-components-from-state.d.ts +2 -3
- package/lib/use-lunatic/commons/get-components-from-state.js +1 -2
- package/lib/use-lunatic/commons/get-components-from-state.js.map +1 -1
- package/lib/use-lunatic/commons/index.d.ts +0 -3
- package/lib/use-lunatic/commons/index.js +0 -3
- package/lib/use-lunatic/commons/index.js.map +1 -1
- package/lib/use-lunatic/commons/page.d.ts +2 -2
- package/lib/use-lunatic/commons/page.js +2 -1
- package/lib/use-lunatic/commons/page.js.map +1 -1
- package/lib/use-lunatic/hooks/use-loop-variables.d.ts +2 -2
- package/lib/use-lunatic/hooks/use-loop-variables.js.map +1 -1
- package/lib/use-lunatic/hooks/use-page-has-response.d.ts +2 -2
- package/lib/use-lunatic/hooks/use-page-has-response.js.map +1 -1
- package/lib/use-lunatic/hooks/useOverview.d.ts +2 -2
- package/lib/use-lunatic/hooks/useOverview.js.map +1 -1
- package/lib/use-lunatic/props/propComponentType.d.ts +9 -0
- package/lib/use-lunatic/{commons/fill-components/fill-specific-expression.js → props/propComponentType.js} +21 -27
- package/lib/use-lunatic/props/propComponentType.js.map +1 -0
- package/lib/use-lunatic/props/propIterations.d.ts +7 -0
- package/lib/use-lunatic/props/propIterations.js +26 -0
- package/lib/use-lunatic/props/propIterations.js.map +1 -0
- package/lib/use-lunatic/props/propMissingResponse.d.ts +9 -0
- package/lib/use-lunatic/props/propMissingResponse.js +13 -0
- package/lib/use-lunatic/props/propMissingResponse.js.map +1 -0
- package/lib/use-lunatic/props/propValue.d.ts +6 -0
- package/lib/use-lunatic/props/propValue.js +28 -0
- package/lib/use-lunatic/props/propValue.js.map +1 -0
- package/lib/use-lunatic/{commons/fill-components/fill-component-value.spec.js → props/propValue.spec.js} +6 -6
- package/lib/use-lunatic/props/propValue.spec.js.map +1 -0
- package/lib/use-lunatic/reducer/commons/auto-explore-loop.d.ts +2 -2
- package/lib/use-lunatic/reducer/commons/auto-explore-loop.js.map +1 -1
- package/lib/use-lunatic/reducer/commons/validate-condition-filter.d.ts +2 -2
- package/lib/use-lunatic/reducer/commons/validate-condition-filter.js.map +1 -1
- package/lib/use-lunatic/reducer/controls/check-base-control.d.ts +2 -2
- package/lib/use-lunatic/reducer/controls/check-base-control.js.map +1 -1
- package/lib/use-lunatic/reducer/controls/check-roundabout-control.d.ts +2 -2
- package/lib/use-lunatic/reducer/controls/check-roundabout-control.js.map +1 -1
- package/lib/use-lunatic/reducer/overview/overviewOnInit.d.ts +4 -105
- package/lib/use-lunatic/reducer/overview/overviewOnInit.js +1 -12
- package/lib/use-lunatic/reducer/overview/overviewOnInit.js.map +1 -1
- package/lib/use-lunatic/reducer/reduce-go-next-page.d.ts +2 -2
- package/lib/use-lunatic/reducer/reduce-go-next-page.js.map +1 -1
- package/lib/use-lunatic/reducer/reduce-go-previous-page.d.ts +2 -3
- package/lib/use-lunatic/reducer/reduce-go-previous-page.js +1 -2
- package/lib/use-lunatic/reducer/reduce-go-previous-page.js.map +1 -1
- package/lib/use-lunatic/reducer/reduce-go-to-page.d.ts +2 -3
- package/lib/use-lunatic/reducer/reduce-go-to-page.js +1 -2
- package/lib/use-lunatic/reducer/reduce-go-to-page.js.map +1 -1
- package/lib/use-lunatic/reducer/reduce-handle-change.d.ts +2 -2
- package/lib/use-lunatic/reducer/reduce-handle-change.js.map +1 -1
- package/lib/use-lunatic/reducer/reducer.d.ts +2 -3
- package/lib/use-lunatic/reducer/reducer.js +3 -10
- package/lib/use-lunatic/reducer/reducer.js.map +1 -1
- package/lib/use-lunatic/reducer/reducerInitializer.d.ts +10 -0
- package/lib/use-lunatic/reducer/{reduce-on-init.js → reducerInitializer.js} +70 -72
- package/lib/use-lunatic/reducer/reducerInitializer.js.map +1 -0
- package/lib/use-lunatic/type.d.ts +77 -49
- package/lib/use-lunatic/use-lunatic.d.ts +23 -69
- package/lib/use-lunatic/use-lunatic.js +69 -74
- package/lib/use-lunatic/use-lunatic.js.map +1 -1
- package/lib/utils/object.d.ts +1 -0
- package/lib/utils/object.js +6 -0
- package/lib/utils/object.js.map +1 -1
- package/package.json +2 -1
- package/lib/stories/behaviour/cleaning/source-loop.json +0 -130
- package/lib/stories/behaviour/resizing/source-resizing-cleaning.json +0 -171
- package/lib/stories/overview/dataLoop.json +0 -189
- package/lib/stories/overview/source.json +0 -28
- package/lib/stories/overview/sourceLoop.json +0 -1423
- package/lib/stories/questionnaires/logement/source.json +0 -31762
- package/lib/stories/questionnaires2023/simpsons/source.json +0 -4728
- package/lib/use-lunatic/commons/fill-components/fill-component-required.d.ts +0 -442
- package/lib/use-lunatic/commons/fill-components/fill-component-required.js +0 -13
- package/lib/use-lunatic/commons/fill-components/fill-component-required.js.map +0 -1
- package/lib/use-lunatic/commons/fill-components/fill-component-value.d.ts +0 -5
- package/lib/use-lunatic/commons/fill-components/fill-component-value.js +0 -34
- package/lib/use-lunatic/commons/fill-components/fill-component-value.js.map +0 -1
- package/lib/use-lunatic/commons/fill-components/fill-component-value.spec.js.map +0 -1
- package/lib/use-lunatic/commons/fill-components/fill-from-state.d.ts +0 -770
- package/lib/use-lunatic/commons/fill-components/fill-from-state.js +0 -18
- package/lib/use-lunatic/commons/fill-components/fill-from-state.js.map +0 -1
- package/lib/use-lunatic/commons/fill-components/fill-iterations.d.ts +0 -124
- package/lib/use-lunatic/commons/fill-components/fill-iterations.js +0 -36
- package/lib/use-lunatic/commons/fill-components/fill-iterations.js.map +0 -1
- package/lib/use-lunatic/commons/fill-components/fill-management.d.ts +0 -6
- package/lib/use-lunatic/commons/fill-components/fill-management.js +0 -9
- package/lib/use-lunatic/commons/fill-components/fill-management.js.map +0 -1
- package/lib/use-lunatic/commons/fill-components/fill-missing-response.d.ts +0 -12
- package/lib/use-lunatic/commons/fill-components/fill-missing-response.js +0 -20
- package/lib/use-lunatic/commons/fill-components/fill-missing-response.js.map +0 -1
- package/lib/use-lunatic/commons/fill-components/fill-pagination.d.ts +0 -9
- package/lib/use-lunatic/commons/fill-components/fill-pagination.js +0 -10
- package/lib/use-lunatic/commons/fill-components/fill-pagination.js.map +0 -1
- package/lib/use-lunatic/commons/fill-components/fill-specific-expression.d.ts +0 -1268
- package/lib/use-lunatic/commons/fill-components/fill-specific-expression.js.map +0 -1
- package/lib/use-lunatic/commons/fill-components/index.d.ts +0 -1
- package/lib/use-lunatic/commons/fill-components/index.js +0 -2
- package/lib/use-lunatic/commons/fill-components/index.js.map +0 -1
- package/lib/use-lunatic/commons/use-components-from-state.d.ts +0 -4
- package/lib/use-lunatic/commons/use-components-from-state.js +0 -15
- package/lib/use-lunatic/commons/use-components-from-state.js.map +0 -1
- package/lib/use-lunatic/initial-state.d.ts +0 -3
- package/lib/use-lunatic/initial-state.js +0 -39
- package/lib/use-lunatic/initial-state.js.map +0 -1
- package/lib/use-lunatic/reducer/index.d.ts +0 -1
- package/lib/use-lunatic/reducer/index.js +0 -2
- package/lib/use-lunatic/reducer/index.js.map +0 -1
- package/lib/use-lunatic/reducer/reduce-on-init.d.ts +0 -4
- package/lib/use-lunatic/reducer/reduce-on-init.js.map +0 -1
- package/lib/use-lunatic/reducer/reduce-on-set-waiting.d.ts +0 -4
- package/lib/use-lunatic/reducer/reduce-on-set-waiting.js +0 -8
- package/lib/use-lunatic/reducer/reduce-on-set-waiting.js.map +0 -1
- package/lib/use-lunatic/use-lunatic.test.d.ts +0 -1
- package/lib/use-lunatic/use-lunatic.test.js +0 -280
- package/lib/use-lunatic/use-lunatic.test.js.map +0 -1
- /package/lib/use-lunatic/{commons/fill-components/fill-component-value.spec.d.ts → props/propValue.spec.d.ts} +0 -0
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import type { ReactNode } from 'react';
|
|
2
|
-
import type { ComponentType, ControlType,
|
|
1
|
+
import type { FunctionComponent, PropsWithChildren, ReactNode } from 'react';
|
|
2
|
+
import type { ComponentType, ControlType, Variable } from './type-source';
|
|
3
3
|
import type { LunaticVariablesStore } from './commons/variables/lunatic-variables-store';
|
|
4
|
+
import type { IndexEntry } from '../utils/search/SearchInterface';
|
|
5
|
+
import type { InterpretedLunaticOverviewItem } from './hooks/useOverview';
|
|
6
|
+
import type { LunaticComponentProps } from '../components/type';
|
|
4
7
|
export type LunaticComponentDefinition<T extends ComponentType['componentType'] = ComponentType['componentType']> = ComponentType & {
|
|
5
8
|
componentType: T;
|
|
6
9
|
};
|
|
@@ -34,7 +37,6 @@ export type LunaticExpression = {
|
|
|
34
37
|
type: ExpressionType;
|
|
35
38
|
bindingDependencies?: string[];
|
|
36
39
|
};
|
|
37
|
-
export type TODO = unknown;
|
|
38
40
|
export type PageTag = `${number}.${number}#${number}` | `${number}`;
|
|
39
41
|
export type LunaticVariable = Variable;
|
|
40
42
|
export type LunaticCollectedValue = Partial<{
|
|
@@ -54,9 +56,21 @@ export type LunaticStateVariable = {
|
|
|
54
56
|
CalculatedLinked?: LunaticVariable[];
|
|
55
57
|
};
|
|
56
58
|
}[LunaticVariable['variableType']];
|
|
57
|
-
export type
|
|
58
|
-
|
|
59
|
+
export type LunaticPager = {
|
|
60
|
+
lastReachedPage?: PageTag;
|
|
61
|
+
maxPage: number;
|
|
62
|
+
nbSubPages?: number;
|
|
63
|
+
page: number;
|
|
64
|
+
subPage?: number;
|
|
65
|
+
iteration?: number;
|
|
66
|
+
nbIterations?: number;
|
|
67
|
+
shallowIteration?: number;
|
|
68
|
+
linksIterations?: number[];
|
|
69
|
+
};
|
|
70
|
+
export type LunaticReducerState = {
|
|
59
71
|
variables: LunaticVariablesStore;
|
|
72
|
+
overview: LunaticOverviewItem[];
|
|
73
|
+
pager: LunaticPager;
|
|
60
74
|
pages: {
|
|
61
75
|
[key: number | string]: {
|
|
62
76
|
components: ComponentType[];
|
|
@@ -72,37 +86,50 @@ export type LunaticState = {
|
|
|
72
86
|
subPages: string[];
|
|
73
87
|
};
|
|
74
88
|
};
|
|
89
|
+
executeExpression: <T extends unknown = unknown>(expression: unknown, args?: {
|
|
90
|
+
iteration?: number | number[];
|
|
91
|
+
bindingDependencies?: string[];
|
|
92
|
+
deps?: string[];
|
|
93
|
+
}) => T;
|
|
94
|
+
isInLoop: boolean;
|
|
95
|
+
updatedAt: number;
|
|
96
|
+
updateBindings: (variableName: string, value: unknown, options: {
|
|
97
|
+
iteration?: number[];
|
|
98
|
+
}) => unknown;
|
|
99
|
+
};
|
|
100
|
+
export type LunaticOptions = {
|
|
101
|
+
features?: ('MD' | 'VTL')[];
|
|
102
|
+
preferences?: ['COLLECTED'];
|
|
103
|
+
savingType?: 'COLLECTED';
|
|
104
|
+
onChange?: LunaticChangeHandler;
|
|
105
|
+
management?: boolean;
|
|
106
|
+
shortcut?: boolean;
|
|
107
|
+
initialPage?: PageTag;
|
|
108
|
+
lastReachedPage?: PageTag;
|
|
109
|
+
autoSuggesterLoading?: boolean;
|
|
110
|
+
getReferentiel?: (name: string) => Promise<Array<IndexEntry>>;
|
|
111
|
+
activeControls?: boolean;
|
|
112
|
+
withOverview?: boolean;
|
|
113
|
+
missing?: boolean;
|
|
114
|
+
missingStrategy?: () => void;
|
|
115
|
+
missingShortcut?: {
|
|
116
|
+
dontKnow: string;
|
|
117
|
+
refused: string;
|
|
118
|
+
};
|
|
119
|
+
dontKnowButton?: string;
|
|
120
|
+
refusedButton?: string;
|
|
121
|
+
trackChanges?: boolean;
|
|
122
|
+
};
|
|
123
|
+
export type LunaticState = {
|
|
124
|
+
pager: LunaticPager;
|
|
125
|
+
overview: InterpretedLunaticOverviewItem[];
|
|
126
|
+
pageTag: PageTag;
|
|
127
|
+
updatedAt: number;
|
|
128
|
+
Provider: FunctionComponent<PropsWithChildren>;
|
|
75
129
|
isInLoop: boolean;
|
|
130
|
+
loopVariables: string[];
|
|
76
131
|
isFirstPage: boolean;
|
|
77
132
|
isLastPage: boolean;
|
|
78
|
-
features: ['VTL'] | ['VTL', 'MD'];
|
|
79
|
-
preferences: ['COLLECTED'];
|
|
80
|
-
savingType: 'COLLECTED';
|
|
81
|
-
cleaning: LunaticSource['cleaning'];
|
|
82
|
-
missingBlock: {
|
|
83
|
-
[variable: string]: string[];
|
|
84
|
-
};
|
|
85
|
-
resizing: {
|
|
86
|
-
[variable: string]: {
|
|
87
|
-
size: string;
|
|
88
|
-
variables: string[];
|
|
89
|
-
sizeForLinksVariables?: unknown;
|
|
90
|
-
linksVariables?: string[];
|
|
91
|
-
};
|
|
92
|
-
};
|
|
93
|
-
overview: LunaticOverviewItem[];
|
|
94
|
-
pager: {
|
|
95
|
-
lastReachedPage?: PageTag;
|
|
96
|
-
maxPage: number;
|
|
97
|
-
nbSubPages?: number;
|
|
98
|
-
page: number;
|
|
99
|
-
subPage?: number;
|
|
100
|
-
iteration?: number;
|
|
101
|
-
nbIterations?: number;
|
|
102
|
-
shallowIteration?: number;
|
|
103
|
-
linksIterations?: number[];
|
|
104
|
-
};
|
|
105
|
-
waiting: boolean;
|
|
106
133
|
errors?: {
|
|
107
134
|
[page: string]: {
|
|
108
135
|
[id: string]: LunaticError[];
|
|
@@ -112,22 +139,6 @@ export type LunaticState = {
|
|
|
112
139
|
[id: string]: LunaticError[];
|
|
113
140
|
};
|
|
114
141
|
modalErrors?: Record<string, LunaticError[]>;
|
|
115
|
-
handleChange: (response: {
|
|
116
|
-
name: string;
|
|
117
|
-
}, value: any, args?: {
|
|
118
|
-
iteration?: number[];
|
|
119
|
-
}) => void;
|
|
120
|
-
executeExpression: <T extends unknown = unknown>(expression: unknown, args?: {
|
|
121
|
-
iteration?: number | number[];
|
|
122
|
-
bindingDependencies?: string[];
|
|
123
|
-
deps?: string[];
|
|
124
|
-
}) => T;
|
|
125
|
-
updateBindings: (variableName: string, value: unknown, options: {
|
|
126
|
-
iteration?: number[];
|
|
127
|
-
}) => unknown;
|
|
128
|
-
activeControls: boolean;
|
|
129
|
-
shortcut?: boolean;
|
|
130
|
-
management?: boolean;
|
|
131
142
|
goToPage: (page: {
|
|
132
143
|
page: PageTag | number;
|
|
133
144
|
iteration?: number;
|
|
@@ -136,4 +147,21 @@ export type LunaticState = {
|
|
|
136
147
|
}) => void;
|
|
137
148
|
goNextPage: () => void;
|
|
138
149
|
goPreviousPage: () => void;
|
|
150
|
+
compileControls: () => void;
|
|
151
|
+
getComponents: (params?: {
|
|
152
|
+
only?: LunaticComponentProps['componentType'];
|
|
153
|
+
except?: LunaticComponentProps['componentType'];
|
|
154
|
+
}) => LunaticComponentProps[];
|
|
155
|
+
getData: (withRefreshedCalculated: boolean, variableNames?: string[]) => LunaticData;
|
|
156
|
+
getChangedData: (reset: boolean) => LunaticData;
|
|
157
|
+
resetChangedData: () => void;
|
|
158
|
+
hasPageResponse: () => boolean;
|
|
159
|
+
testing: {
|
|
160
|
+
handleChange: LunaticChangeHandler;
|
|
161
|
+
};
|
|
139
162
|
};
|
|
163
|
+
export type LunaticChangeHandler = (response: {
|
|
164
|
+
name: string;
|
|
165
|
+
}, value: any, args?: {
|
|
166
|
+
iteration?: number[];
|
|
167
|
+
}) => void;
|
|
@@ -1,71 +1,29 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
|
-
import type {
|
|
2
|
+
import type { LunaticChangeHandler, LunaticData, LunaticOptions, PageTag } from './type';
|
|
3
3
|
import type { LunaticSource } from './type-source';
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
savingType?: LunaticState['savingType'];
|
|
18
|
-
onChange?: LunaticState['handleChange'];
|
|
19
|
-
management?: boolean;
|
|
20
|
-
shortcut?: boolean;
|
|
21
|
-
initialPage?: PageTag;
|
|
22
|
-
lastReachedPage?: PageTag;
|
|
23
|
-
autoSuggesterLoading?: boolean;
|
|
24
|
-
getReferentiel?: (name: string) => Promise<Array<IndexEntry>>;
|
|
25
|
-
activeControls?: boolean;
|
|
26
|
-
withOverview?: boolean;
|
|
27
|
-
missing?: boolean;
|
|
28
|
-
missingStrategy?: () => void;
|
|
29
|
-
missingShortcut?: {
|
|
30
|
-
dontKnow: string;
|
|
31
|
-
refused: string;
|
|
32
|
-
};
|
|
33
|
-
dontKnowButton?: string;
|
|
34
|
-
refusedButton?: string;
|
|
35
|
-
trackChanges?: boolean;
|
|
36
|
-
}): {
|
|
37
|
-
getComponents: ({ only, except, }?: {
|
|
38
|
-
only?: LunaticComponentProps['componentType'];
|
|
39
|
-
except?: LunaticComponentProps['componentType'];
|
|
40
|
-
}) => LunaticComponentProps[];
|
|
4
|
+
declare function useLunatic(source: LunaticSource, data?: LunaticData, argOptions?: LunaticOptions): {
|
|
5
|
+
pageTag: PageTag;
|
|
6
|
+
isFirstPage: boolean;
|
|
7
|
+
isLastPage: boolean;
|
|
8
|
+
updatedAt: number;
|
|
9
|
+
pager: import("./type").LunaticPager;
|
|
10
|
+
isInLoop: boolean;
|
|
11
|
+
overview: import("./hooks/useOverview").InterpretedLunaticOverviewItem[];
|
|
12
|
+
loopVariables: string[];
|
|
13
|
+
getComponents: (params?: {
|
|
14
|
+
only?: "Sequence" | "Subsequence" | "RosterForLoop" | "Loop" | "Table" | "InputNumber" | "Datepicker" | "Duration" | "CheckboxGroup" | "CheckboxBoolean" | "Radio" | "FilterDescription" | "Dropdown" | "PairwiseLinks" | "Roundabout" | "Suggester" | "Input" | "Textarea" | "CheckboxOne" | "Question" | "Switch" | "Summary" | undefined;
|
|
15
|
+
except?: "Sequence" | "Subsequence" | "RosterForLoop" | "Loop" | "Table" | "InputNumber" | "Datepicker" | "Duration" | "CheckboxGroup" | "CheckboxBoolean" | "Radio" | "FilterDescription" | "Dropdown" | "PairwiseLinks" | "Roundabout" | "Suggester" | "Input" | "Textarea" | "CheckboxOne" | "Question" | "Switch" | "Summary" | undefined;
|
|
16
|
+
} | undefined) => import("..").LunaticComponentProps[];
|
|
41
17
|
goPreviousPage: () => void;
|
|
42
|
-
goNextPage: (
|
|
18
|
+
goNextPage: () => void;
|
|
43
19
|
goToPage: (page: {
|
|
44
20
|
page: number | PageTag;
|
|
45
21
|
iteration?: number | undefined;
|
|
46
22
|
nbIterations?: number | undefined;
|
|
47
23
|
subPage?: number | undefined;
|
|
48
24
|
}) => void;
|
|
49
|
-
compileControls: () =>
|
|
50
|
-
|
|
51
|
-
isCritical: boolean;
|
|
52
|
-
};
|
|
53
|
-
pageTag: PageTag;
|
|
54
|
-
isFirstPage: boolean;
|
|
55
|
-
isLastPage: boolean;
|
|
56
|
-
pager: {
|
|
57
|
-
lastReachedPage?: PageTag | undefined;
|
|
58
|
-
maxPage: number;
|
|
59
|
-
nbSubPages?: number | undefined;
|
|
60
|
-
page: number;
|
|
61
|
-
subPage?: number | undefined;
|
|
62
|
-
iteration?: number | undefined;
|
|
63
|
-
nbIterations?: number | undefined;
|
|
64
|
-
shallowIteration?: number | undefined;
|
|
65
|
-
linksIterations?: number[] | undefined;
|
|
66
|
-
};
|
|
67
|
-
waiting: boolean;
|
|
68
|
-
getData: (withRefreshedCalculated: boolean, variableNames?: string[]) => Partial<Record<"EXTERNAL" | "CALCULATED", Record<string, unknown>> & {
|
|
25
|
+
compileControls: () => void;
|
|
26
|
+
getData: (withRefreshedCalculated: boolean, variableNames?: string[] | undefined) => Partial<Record<"EXTERNAL" | "CALCULATED", Record<string, unknown>> & {
|
|
69
27
|
COLLECTED: Record<string, Partial<{
|
|
70
28
|
COLLECTED: unknown;
|
|
71
29
|
EDITED: unknown;
|
|
@@ -74,16 +32,6 @@ declare function useLunatic(source: LunaticSource, data: Partial<Record<"EXTERNA
|
|
|
74
32
|
PREVIOUS: unknown;
|
|
75
33
|
}>>;
|
|
76
34
|
}>;
|
|
77
|
-
Provider: import("react").FunctionComponent<{
|
|
78
|
-
children?: import("react").ReactNode;
|
|
79
|
-
}>;
|
|
80
|
-
onChange: (response: {
|
|
81
|
-
name: string;
|
|
82
|
-
}, value: any, args?: {
|
|
83
|
-
iteration?: number[] | undefined;
|
|
84
|
-
} | undefined) => void;
|
|
85
|
-
overview: import("./hooks/useOverview").InterpretedLunaticOverviewItem[];
|
|
86
|
-
loopVariables: string[];
|
|
87
35
|
getChangedData: (reset?: boolean) => Partial<Record<"EXTERNAL" | "CALCULATED", Record<string, unknown>> & {
|
|
88
36
|
COLLECTED: Record<string, Partial<{
|
|
89
37
|
COLLECTED: unknown;
|
|
@@ -95,5 +43,11 @@ declare function useLunatic(source: LunaticSource, data: Partial<Record<"EXTERNA
|
|
|
95
43
|
}>;
|
|
96
44
|
resetChangedData: () => void;
|
|
97
45
|
hasPageResponse: () => boolean;
|
|
46
|
+
Provider: import("react").FunctionComponent<{
|
|
47
|
+
children?: import("react").ReactNode;
|
|
48
|
+
}>;
|
|
49
|
+
testing: {
|
|
50
|
+
handleChange: LunaticChangeHandler;
|
|
51
|
+
};
|
|
98
52
|
};
|
|
99
53
|
export default useLunatic;
|
|
@@ -1,35 +1,54 @@
|
|
|
1
1
|
import { useCallback, useEffect, useMemo, useReducer } from 'react';
|
|
2
2
|
import * as actions from './actions';
|
|
3
|
-
import { getPageTag, isFirstLastPage
|
|
3
|
+
import { getPageTag, isFirstLastPage } from './commons';
|
|
4
4
|
import D from '../i18n';
|
|
5
5
|
import { COLLECTED } from '../utils/constants';
|
|
6
|
-
import INITIAL_STATE from './initial-state';
|
|
7
6
|
import { createLunaticProvider } from './lunatic-context';
|
|
8
7
|
import { compileControls as compileControlsLib } from './commons/compile-controls';
|
|
9
8
|
import { useLoopVariables } from './hooks/use-loop-variables';
|
|
10
|
-
import reducer from './reducer';
|
|
11
9
|
import { getQuestionnaireData } from './commons/variables/get-questionnaire-data';
|
|
12
10
|
import { useTrackChanges } from '../hooks/use-track-changes';
|
|
13
11
|
import { usePageHasResponse } from './hooks/use-page-has-response';
|
|
14
12
|
import { registerSuggesters } from '../utils/search/SuggestersDatabase';
|
|
15
13
|
import { useRefSync } from '../hooks/useRefSync';
|
|
16
14
|
import { useOverview } from './hooks/useOverview';
|
|
15
|
+
import { reducerInitializer } from './reducer/reducerInitializer';
|
|
16
|
+
import { getComponentsFromState } from './commons/get-components-from-state';
|
|
17
|
+
import { fillComponents } from './commons/fill-components/fill-components';
|
|
18
|
+
import { reducer } from './reducer/reducer';
|
|
19
|
+
import { mergeDefault } from '../utils/object';
|
|
17
20
|
const empty = {}; // Keep the same empty object (to avoid problem with useEffect dependencies)
|
|
18
|
-
const emptyFn = () => { };
|
|
19
21
|
const DEFAULT_DATA = empty;
|
|
20
22
|
const DEFAULT_FEATURES = ['VTL', 'MD'];
|
|
21
23
|
const DEFAULT_PREFERENCES = [COLLECTED];
|
|
22
24
|
const DEFAULT_SHORTCUT = { dontKnow: '', refused: '' };
|
|
23
25
|
const DEFAULT_DONT_KNOW = D.DK;
|
|
24
26
|
const DEFAULT_REFUSED = D.RF;
|
|
25
|
-
const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
27
|
+
const defaultOptions = {
|
|
28
|
+
features: DEFAULT_FEATURES,
|
|
29
|
+
preferences: DEFAULT_PREFERENCES,
|
|
30
|
+
savingType: COLLECTED,
|
|
31
|
+
onChange: () => { },
|
|
32
|
+
management: false,
|
|
33
|
+
shortcut: false,
|
|
34
|
+
initialPage: '1',
|
|
35
|
+
lastReachedPage: undefined,
|
|
36
|
+
autoSuggesterLoading: false,
|
|
37
|
+
activeControls: false,
|
|
38
|
+
// Calculate an overview of every sequence (will be exposed as "overview")
|
|
39
|
+
withOverview: false,
|
|
40
|
+
missing: false,
|
|
41
|
+
missingStrategy: () => { },
|
|
42
|
+
missingShortcut: DEFAULT_SHORTCUT,
|
|
43
|
+
dontKnowButton: DEFAULT_DONT_KNOW,
|
|
44
|
+
refusedButton: DEFAULT_REFUSED,
|
|
45
|
+
trackChanges: false,
|
|
46
|
+
};
|
|
47
|
+
function useLunatic(source, data = DEFAULT_DATA, argOptions = empty) {
|
|
48
|
+
const options = mergeDefault(argOptions, defaultOptions);
|
|
49
|
+
const { management, missing, missingStrategy, shortcut, missingShortcut, dontKnowButton, refusedButton, onChange, trackChanges, preferences, } = options;
|
|
50
|
+
const [state, dispatch] = useReducer(reducer, { ...options, source, data }, reducerInitializer);
|
|
51
|
+
const getReferentielRef = useRefSync(options.getReferentiel);
|
|
33
52
|
// Register the list of suggesters
|
|
34
53
|
useEffect(() => {
|
|
35
54
|
if (source.suggesters && getReferentielRef.current) {
|
|
@@ -54,9 +73,9 @@ withOverview = false, missing = false, missingStrategy = emptyFn, missingShortcu
|
|
|
54
73
|
dontKnowButton,
|
|
55
74
|
refusedButton,
|
|
56
75
|
]);
|
|
57
|
-
const compileControls =
|
|
58
|
-
return compileControlsLib(
|
|
59
|
-
}
|
|
76
|
+
const compileControls = () => {
|
|
77
|
+
return compileControlsLib(state);
|
|
78
|
+
};
|
|
60
79
|
const goPreviousPage = useCallback(function () {
|
|
61
80
|
dispatch(actions.goPreviousPage());
|
|
62
81
|
}, [dispatch]);
|
|
@@ -66,18 +85,6 @@ withOverview = false, missing = false, missingStrategy = emptyFn, missingShortcu
|
|
|
66
85
|
const goToPage = useCallback(function (payload) {
|
|
67
86
|
dispatch(actions.goToPage(payload));
|
|
68
87
|
}, [dispatch]);
|
|
69
|
-
const getComponents = useCallback(function ({ only, except, } = {}) {
|
|
70
|
-
if (only && except) {
|
|
71
|
-
throw new Error('"only" and "except" cannot be used together in getComponents()');
|
|
72
|
-
}
|
|
73
|
-
if (only) {
|
|
74
|
-
return components.filter((c) => only.includes(c.componentType ?? ''));
|
|
75
|
-
}
|
|
76
|
-
if (except) {
|
|
77
|
-
return components.filter((c) => !except.includes(c.componentType ?? ''));
|
|
78
|
-
}
|
|
79
|
-
return components;
|
|
80
|
-
}, [components]);
|
|
81
88
|
const handleChange = useCallback((response, value, args) => {
|
|
82
89
|
dispatch(actions.handleChange(typeof response === 'string' ? response : response.name, value, args?.iteration));
|
|
83
90
|
onChange(response, value, args);
|
|
@@ -86,66 +93,54 @@ withOverview = false, missing = false, missingStrategy = emptyFn, missingShortcu
|
|
|
86
93
|
return getQuestionnaireData(state.variables, source.variables, withRefreshedCalculated, variableNames);
|
|
87
94
|
};
|
|
88
95
|
const { resetChangedData, getChangedData } = useTrackChanges(trackChanges, state.variables, (variableNames) => getData(false, variableNames));
|
|
89
|
-
const pageTag = getPageTag(pager);
|
|
90
|
-
const { isFirstPage, isLastPage } = isFirstLastPage(pager);
|
|
91
|
-
|
|
92
|
-
dispatch(actions.onInit({
|
|
93
|
-
source,
|
|
94
|
-
data,
|
|
95
|
-
initialPage,
|
|
96
|
-
lastReachedPage,
|
|
97
|
-
features,
|
|
98
|
-
preferences,
|
|
99
|
-
savingType,
|
|
100
|
-
management,
|
|
101
|
-
shortcut,
|
|
102
|
-
handleChange,
|
|
103
|
-
activeControls,
|
|
104
|
-
goToPage,
|
|
105
|
-
goNextPage,
|
|
106
|
-
goPreviousPage,
|
|
107
|
-
withOverview,
|
|
108
|
-
}));
|
|
109
|
-
}, [
|
|
110
|
-
source,
|
|
111
|
-
data,
|
|
112
|
-
initialPage,
|
|
113
|
-
features,
|
|
114
|
-
preferences,
|
|
115
|
-
savingType,
|
|
116
|
-
management,
|
|
117
|
-
shortcut,
|
|
96
|
+
const pageTag = getPageTag(state.pager);
|
|
97
|
+
const { isFirstPage, isLastPage } = isFirstLastPage(state.pager);
|
|
98
|
+
const components = fillComponents(getComponentsFromState(state), {
|
|
118
99
|
handleChange,
|
|
119
|
-
|
|
120
|
-
withOverview,
|
|
100
|
+
preferences,
|
|
121
101
|
goToPage,
|
|
102
|
+
shortcut,
|
|
122
103
|
goNextPage,
|
|
123
104
|
goPreviousPage,
|
|
124
|
-
|
|
125
|
-
|
|
105
|
+
management,
|
|
106
|
+
...state,
|
|
107
|
+
});
|
|
108
|
+
const getComponents = ({ only, except, } = {}) => {
|
|
109
|
+
if (only && except) {
|
|
110
|
+
throw new Error('"only" and "except" cannot be used together in getComponents()');
|
|
111
|
+
}
|
|
112
|
+
if (only) {
|
|
113
|
+
return components.filter((c) => only.includes(c.componentType ?? ''));
|
|
114
|
+
}
|
|
115
|
+
if (except) {
|
|
116
|
+
return components.filter((c) => !except.includes(c.componentType ?? ''));
|
|
117
|
+
}
|
|
118
|
+
return components;
|
|
119
|
+
};
|
|
126
120
|
return {
|
|
121
|
+
pageTag,
|
|
122
|
+
isFirstPage,
|
|
123
|
+
isLastPage,
|
|
124
|
+
updatedAt: state.updatedAt,
|
|
125
|
+
pager: state.pager,
|
|
126
|
+
isInLoop: state.isInLoop,
|
|
127
|
+
overview: useOverview(state, [pageTag]),
|
|
128
|
+
loopVariables: useLoopVariables(state.pager, state.pages),
|
|
129
|
+
// Methods
|
|
127
130
|
getComponents,
|
|
128
131
|
goPreviousPage,
|
|
129
132
|
goNextPage,
|
|
130
133
|
goToPage,
|
|
131
134
|
compileControls,
|
|
132
|
-
pageTag,
|
|
133
|
-
isFirstPage,
|
|
134
|
-
isLastPage,
|
|
135
|
-
pager,
|
|
136
|
-
waiting,
|
|
137
135
|
getData,
|
|
138
|
-
Provider,
|
|
139
|
-
onChange: handleChange,
|
|
140
|
-
overview: useOverview({
|
|
141
|
-
executeExpression,
|
|
142
|
-
overview,
|
|
143
|
-
pager,
|
|
144
|
-
}, [pageTag]),
|
|
145
|
-
loopVariables: useLoopVariables(pager, state.pages),
|
|
146
136
|
getChangedData,
|
|
147
137
|
resetChangedData,
|
|
148
|
-
hasPageResponse: usePageHasResponse(components, executeExpression),
|
|
138
|
+
hasPageResponse: usePageHasResponse(components, state.executeExpression),
|
|
139
|
+
// Components
|
|
140
|
+
Provider,
|
|
141
|
+
testing: {
|
|
142
|
+
handleChange,
|
|
143
|
+
},
|
|
149
144
|
};
|
|
150
145
|
}
|
|
151
146
|
export default useLunatic;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"use-lunatic.js","sourceRoot":"","sources":["../../src/use-lunatic/use-lunatic.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS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<T extends Record<string, any>, V extends unknown>(object: T, callback: (k: keyof T, v: T[keyof T]) => [k: keyof T, v: V] | null): Record<keyof T, V>;
|
|
5
5
|
export declare function objectKeys<T extends Record<string, unknown>>(object: T): (keyof T)[];
|
|
6
|
+
export declare function mergeDefault<T extends Record<string, unknown>, D extends Record<string, unknown>>(obj: T, defaults: D): T & D;
|
package/lib/utils/object.js
CHANGED
|
@@ -17,4 +17,10 @@ export function objectMap(object, callback) {
|
|
|
17
17
|
export function objectKeys(object) {
|
|
18
18
|
return Object.keys(object);
|
|
19
19
|
}
|
|
20
|
+
export function mergeDefault(obj, defaults) {
|
|
21
|
+
return objectMap({ ...obj, ...defaults }, (k) => {
|
|
22
|
+
// @ts-ignore Ignore this line since TS is not able to handle this case
|
|
23
|
+
return [k, obj[k] ?? defaults[k]];
|
|
24
|
+
});
|
|
25
|
+
}
|
|
20
26
|
//# sourceMappingURL=object.js.map
|
package/lib/utils/object.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"object.js","sourceRoot":"","sources":["../../src/utils/object.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,MAAM,UAAU,SAAS,CACxB,MAAS,EACT,QAAkE;IAElE,OAAO,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,MAAM,CACnC,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE;QACf,MAAM,MAAM,GAAG,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QAC9B,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,MAAM,CAAC,EAAE,CAAC;YAC5B,OAAO,GAAG,CAAC;QACZ,CAAC;QACD,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,GAAG,MAAM,CAAC;QAC5B,GAAG,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACjB,OAAO,GAAG,CAAC;IACZ,CAAC,EACD,EAAwB,CACxB,CAAC;AACH,CAAC;AACD,6EA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2
2
|
"name": "@inseefr/lunatic",
|
|
3
|
-
"version": "3.0.0-rc.
|
|
3
|
+
"version": "3.0.0-rc.27",
|
|
4
4
|
"description": "Library of questionnaire components",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -70,6 +70,7 @@
|
|
|
70
70
|
"react-markdown": "^8.0.3",
|
|
71
71
|
"react-number-format": "^5.1.3",
|
|
72
72
|
"react-tooltip": "^5.23.0",
|
|
73
|
+
"remark-breaks": "^4.0.0",
|
|
73
74
|
"sass": "^1.58.3"
|
|
74
75
|
},
|
|
75
76
|
"resolutions": {
|