@inseefr/lunatic 3.13.4 → 3.13.5-rc-fix-multimode.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/Duration/getDurationFromValue.d.ts +2 -2
- package/components/Duration/getDurationFromValue.js +7 -6
- package/components/Duration/getDurationFromValue.js.map +1 -1
- package/components/Suggester/CustomSuggester.d.ts +1 -0
- package/components/Suggester/CustomSuggester.js +2 -2
- package/components/Suggester/CustomSuggester.js.map +1 -1
- package/components/Suggester/CustomSuggester.spec.d.ts +1 -0
- package/components/Suggester/CustomSuggester.spec.js +32 -0
- package/components/Suggester/CustomSuggester.spec.js.map +1 -0
- package/components/Suggester/Suggester.d.ts +1 -1
- package/components/Suggester/Suggester.js +2 -2
- package/components/Suggester/Suggester.js.map +1 -1
- package/components/shared/Combobox/Combobox.js +2 -2
- package/components/shared/Combobox/Combobox.js.map +1 -1
- package/components/shared/Combobox/ComboboxType.d.ts +1 -0
- package/components/shared/Combobox/Selection/ComboboxInput.d.ts +1 -0
- package/components/shared/Combobox/Selection/ComboboxInput.js +2 -2
- package/components/shared/Combobox/Selection/ComboboxInput.js.map +1 -1
- package/components/shared/Combobox/Selection/ComboboxSelection.d.ts +1 -1
- package/components/shared/Combobox/Selection/ComboboxSelection.js +3 -3
- package/components/shared/Combobox/Selection/ComboboxSelection.js.map +1 -1
- package/esm/components/Duration/getDurationFromValue.d.ts +2 -2
- package/esm/components/Duration/getDurationFromValue.js +7 -6
- package/esm/components/Duration/getDurationFromValue.js.map +1 -1
- package/esm/components/Suggester/CustomSuggester.d.ts +1 -0
- package/esm/components/Suggester/CustomSuggester.js +2 -2
- package/esm/components/Suggester/CustomSuggester.js.map +1 -1
- package/esm/components/Suggester/CustomSuggester.spec.d.ts +1 -0
- package/esm/components/Suggester/CustomSuggester.spec.js +30 -0
- package/esm/components/Suggester/CustomSuggester.spec.js.map +1 -0
- package/esm/components/Suggester/Suggester.d.ts +1 -1
- package/esm/components/Suggester/Suggester.js +2 -2
- package/esm/components/Suggester/Suggester.js.map +1 -1
- package/esm/components/shared/Combobox/Combobox.js +2 -2
- package/esm/components/shared/Combobox/Combobox.js.map +1 -1
- package/esm/components/shared/Combobox/ComboboxType.d.ts +1 -0
- package/esm/components/shared/Combobox/Selection/ComboboxInput.d.ts +1 -0
- package/esm/components/shared/Combobox/Selection/ComboboxInput.js +2 -2
- package/esm/components/shared/Combobox/Selection/ComboboxInput.js.map +1 -1
- package/esm/components/shared/Combobox/Selection/ComboboxSelection.d.ts +1 -1
- package/esm/components/shared/Combobox/Selection/ComboboxSelection.js +3 -3
- package/esm/components/shared/Combobox/Selection/ComboboxSelection.js.map +1 -1
- package/esm/hooks/useMultimode.js +21 -10
- package/esm/hooks/useMultimode.js.map +1 -1
- package/esm/use-lunatic/commons/compile-controls.d.ts +5 -0
- package/esm/use-lunatic/commons/compile-controls.js +6 -1
- package/esm/use-lunatic/commons/compile-controls.js.map +1 -1
- package/esm/use-lunatic/commons/compile-controls.spec.d.ts +1 -0
- package/esm/use-lunatic/commons/compile-controls.spec.js +121 -0
- package/esm/use-lunatic/commons/compile-controls.spec.js.map +1 -0
- package/esm/utils/getArticulationState.js +12 -6
- package/esm/utils/getArticulationState.js.map +1 -1
- package/hooks/useMultimode.js +20 -8
- package/hooks/useMultimode.js.map +1 -1
- package/package.json +21 -3
- package/src/components/Dropdown/__snapshots__/Dropdown.spec.tsx.snap +0 -2
- package/src/components/Duration/getDurationFromValue.ts +10 -6
- package/src/components/Suggester/CustomSuggester.spec.tsx +32 -0
- package/src/components/Suggester/CustomSuggester.tsx +3 -0
- package/src/components/Suggester/Suggester.tsx +2 -0
- package/src/components/shared/Combobox/Combobox.tsx +2 -0
- package/src/components/shared/Combobox/ComboboxType.ts +1 -0
- package/src/components/shared/Combobox/Selection/ComboboxInput.tsx +4 -0
- package/src/components/shared/Combobox/Selection/ComboboxSelection.tsx +3 -2
- package/src/components/shared/Combobox/Selection/__snapshots__/ComboboxSelection.spec.tsx.snap +0 -4
- package/src/hooks/useMultimode.ts +27 -13
- package/src/stories/questionnaires/SRCV/data.json +116 -0
- package/src/stories/questionnaires/SRCV/source.json +69256 -0
- package/src/stories/questionnaires/SRCV/srcv.stories.tsx +23 -0
- package/src/use-lunatic/commons/compile-controls.spec.ts +136 -0
- package/src/use-lunatic/commons/compile-controls.ts +7 -1
- package/src/utils/getArticulationState.ts +16 -8
- package/tsconfig.build.tsbuildinfo +1 -1
- package/use-lunatic/commons/compile-controls.d.ts +5 -0
- package/use-lunatic/commons/compile-controls.js +6 -0
- package/use-lunatic/commons/compile-controls.js.map +1 -1
- package/use-lunatic/commons/compile-controls.spec.d.ts +1 -0
- package/use-lunatic/commons/compile-controls.spec.js +123 -0
- package/use-lunatic/commons/compile-controls.spec.js.map +1 -0
- package/utils/getArticulationState.js +12 -6
- package/utils/getArticulationState.js.map +1 -1
|
@@ -35,6 +35,7 @@ export function WrappedSuggester({
|
|
|
35
35
|
iteration,
|
|
36
36
|
arbitrary,
|
|
37
37
|
arbitraryValue,
|
|
38
|
+
required,
|
|
38
39
|
}: LunaticComponentProps<'Suggester'>) {
|
|
39
40
|
const { store, storeState, setStoreState, getLabelById } = useStore({
|
|
40
41
|
storeName,
|
|
@@ -182,6 +183,7 @@ export function WrappedSuggester({
|
|
|
182
183
|
onClear={handleClear}
|
|
183
184
|
disabled={disabled}
|
|
184
185
|
readOnly={readOnly}
|
|
186
|
+
required={required}
|
|
185
187
|
value={selectedOptions}
|
|
186
188
|
label={label}
|
|
187
189
|
onBlur={onBlur}
|
|
@@ -68,6 +68,7 @@ function LunaticComboBox({
|
|
|
68
68
|
onBlur,
|
|
69
69
|
onFocus,
|
|
70
70
|
isLoading,
|
|
71
|
+
required,
|
|
71
72
|
}: Props) {
|
|
72
73
|
const [expanded, setExpanded] = useState(false);
|
|
73
74
|
const [focused, setFocused] = useState(false);
|
|
@@ -180,6 +181,7 @@ function LunaticComboBox({
|
|
|
180
181
|
onChange={handleChange}
|
|
181
182
|
classNamePrefix={classNamePrefix}
|
|
182
183
|
invalid={!!errors}
|
|
184
|
+
required={required}
|
|
183
185
|
/>
|
|
184
186
|
<ComboboxPanel
|
|
185
187
|
isLoading={isLoading}
|
|
@@ -15,6 +15,7 @@ export type InputProps = {
|
|
|
15
15
|
focused?: boolean;
|
|
16
16
|
invalid?: boolean;
|
|
17
17
|
readOnly?: boolean;
|
|
18
|
+
required?: boolean;
|
|
18
19
|
} & HTMLAttributes<HTMLInputElement>;
|
|
19
20
|
|
|
20
21
|
function LunaticComboboxInput({
|
|
@@ -27,6 +28,7 @@ function LunaticComboboxInput({
|
|
|
27
28
|
focused,
|
|
28
29
|
className,
|
|
29
30
|
invalid,
|
|
31
|
+
required,
|
|
30
32
|
}: InputProps) {
|
|
31
33
|
const inputEl = useRef<HTMLInputElement>(null);
|
|
32
34
|
|
|
@@ -52,6 +54,8 @@ function LunaticComboboxInput({
|
|
|
52
54
|
onChange={onChange}
|
|
53
55
|
value={value}
|
|
54
56
|
aria-invalid={invalid}
|
|
57
|
+
aria-required={required}
|
|
58
|
+
required={required}
|
|
55
59
|
title="combo-box"
|
|
56
60
|
autoComplete="off"
|
|
57
61
|
autoCapitalize="off"
|
|
@@ -24,10 +24,11 @@ export function ComboboxSelection({
|
|
|
24
24
|
id,
|
|
25
25
|
classNamePrefix,
|
|
26
26
|
invalid,
|
|
27
|
+
required,
|
|
27
28
|
}: ComboboxSelectionProps) {
|
|
28
29
|
const showLabel = !editable || !expanded;
|
|
29
30
|
const selectedOption =
|
|
30
|
-
selectedIndex
|
|
31
|
+
selectedIndex === undefined ? undefined : options[selectedIndex];
|
|
31
32
|
const LabelSelectionComponent = labelRenderer ?? ComboboxLabelSelection;
|
|
32
33
|
|
|
33
34
|
return (
|
|
@@ -41,7 +42,6 @@ export function ComboboxSelection({
|
|
|
41
42
|
}
|
|
42
43
|
)}
|
|
43
44
|
role="combobox"
|
|
44
|
-
aria-controls={'todo'}
|
|
45
45
|
aria-haspopup="listbox"
|
|
46
46
|
aria-expanded={expanded}
|
|
47
47
|
aria-autocomplete="list"
|
|
@@ -70,6 +70,7 @@ export function ComboboxSelection({
|
|
|
70
70
|
readOnly={readOnly}
|
|
71
71
|
focused={focused}
|
|
72
72
|
labelledBy={labelId}
|
|
73
|
+
required={required}
|
|
73
74
|
/>
|
|
74
75
|
)}
|
|
75
76
|
</div>
|
package/src/components/shared/Combobox/Selection/__snapshots__/ComboboxSelection.spec.tsx.snap
CHANGED
|
@@ -3,7 +3,6 @@
|
|
|
3
3
|
exports[`Selection component > should render correctly when it is disabled 1`] = `
|
|
4
4
|
<div
|
|
5
5
|
aria-autocomplete="list"
|
|
6
|
-
aria-controls="todo"
|
|
7
6
|
aria-haspopup="listbox"
|
|
8
7
|
class="lunatic-combo-box-selection disabled"
|
|
9
8
|
role="combobox"
|
|
@@ -23,7 +22,6 @@ exports[`Selection component > should render correctly when it is disabled 1`] =
|
|
|
23
22
|
exports[`Selection component > should render correctly when it is editable 1`] = `
|
|
24
23
|
<div
|
|
25
24
|
aria-autocomplete="list"
|
|
26
|
-
aria-controls="todo"
|
|
27
25
|
aria-haspopup="listbox"
|
|
28
26
|
class="lunatic-combo-box-selection"
|
|
29
27
|
role="combobox"
|
|
@@ -41,7 +39,6 @@ exports[`Selection component > should render correctly when it is editable 1`] =
|
|
|
41
39
|
exports[`Selection component > should render correctly when it is expanded 1`] = `
|
|
42
40
|
<div
|
|
43
41
|
aria-autocomplete="list"
|
|
44
|
-
aria-controls="todo"
|
|
45
42
|
aria-expanded="true"
|
|
46
43
|
aria-haspopup="listbox"
|
|
47
44
|
class="lunatic-combo-box-selection"
|
|
@@ -60,7 +57,6 @@ exports[`Selection component > should render correctly when it is expanded 1`] =
|
|
|
60
57
|
exports[`Selection component > should render correctly with default props 1`] = `
|
|
61
58
|
<div
|
|
62
59
|
aria-autocomplete="list"
|
|
63
|
-
aria-controls="todo"
|
|
64
60
|
aria-haspopup="listbox"
|
|
65
61
|
class="lunatic-combo-box-selection"
|
|
66
62
|
role="combobox"
|
|
@@ -55,22 +55,37 @@ export function useMultimode(
|
|
|
55
55
|
return {};
|
|
56
56
|
}
|
|
57
57
|
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
58
|
+
// Initialize rules to empty objects if they do not exist
|
|
59
|
+
const questionnaireRules = source.multimode.questionnaire?.rules || {};
|
|
60
|
+
const leafRules = source.multimode.leaf?.rules || {};
|
|
61
|
+
|
|
62
|
+
// If neither has rules, return an empty object
|
|
63
|
+
if (Object.keys(questionnaireRules).length === 0 && Object.keys(leafRules).length === 0) {
|
|
64
|
+
return {};
|
|
65
|
+
}
|
|
62
66
|
|
|
67
|
+
// Get unique rule keys
|
|
63
68
|
const keys = new Set([
|
|
64
|
-
...Object.keys(
|
|
65
|
-
...Object.keys(
|
|
69
|
+
...Object.keys(questionnaireRules),
|
|
70
|
+
...Object.keys(leafRules),
|
|
66
71
|
]);
|
|
67
|
-
|
|
72
|
+
|
|
73
|
+
// Handle the case where leaf.source exists to retrieve iterations
|
|
74
|
+
let iterations = 0;
|
|
75
|
+
if (source.multimode.leaf?.source) {
|
|
76
|
+
const roundabout = findComponentById(
|
|
77
|
+
source.components,
|
|
78
|
+
source.multimode.leaf.source
|
|
79
|
+
);
|
|
80
|
+
iterations = forceInt(
|
|
81
|
+
store.run(roundabout?.iterations?.value ?? '') ?? 0
|
|
82
|
+
);
|
|
83
|
+
}
|
|
68
84
|
|
|
69
85
|
return Object.fromEntries(
|
|
70
86
|
Array.from(keys).map((key) => {
|
|
71
|
-
// Check the
|
|
72
|
-
const questionnaireExpression =
|
|
73
|
-
source.multimode?.questionnaire.rules[key];
|
|
87
|
+
// Check the rule at the questionnaire level
|
|
88
|
+
const questionnaireExpression = questionnaireRules[key];
|
|
74
89
|
if (
|
|
75
90
|
questionnaireExpression &&
|
|
76
91
|
store.run(questionnaireExpression.value)
|
|
@@ -78,9 +93,8 @@ export function useMultimode(
|
|
|
78
93
|
return [key, true];
|
|
79
94
|
}
|
|
80
95
|
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
// There is no expression for the leaf
|
|
96
|
+
// Check the rule at the leaf level
|
|
97
|
+
const leafExpression = leafRules[key];
|
|
84
98
|
if (!leafExpression) {
|
|
85
99
|
return [key, false];
|
|
86
100
|
}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "5a90586e-a2a3-4853-aa3a-f8ebd0f6e86b",
|
|
3
|
+
"questionnaireId": "4552-CAPI",
|
|
4
|
+
"personalization": [],
|
|
5
|
+
"data": {
|
|
6
|
+
"EXTERNAL": {
|
|
7
|
+
"ADR": "1 RUE DU GRAND CHENE 79200 PARTHENAY",
|
|
8
|
+
"TROPIQUE": "1"
|
|
9
|
+
},
|
|
10
|
+
"COLLECTED": {
|
|
11
|
+
"RESIND": [],
|
|
12
|
+
"LIENS": {
|
|
13
|
+
"COLLECTED": [
|
|
14
|
+
[
|
|
15
|
+
null,
|
|
16
|
+
"17",
|
|
17
|
+
"17"
|
|
18
|
+
],
|
|
19
|
+
[
|
|
20
|
+
"17",
|
|
21
|
+
null,
|
|
22
|
+
"17"
|
|
23
|
+
],
|
|
24
|
+
[
|
|
25
|
+
"17",
|
|
26
|
+
"17"
|
|
27
|
+
]
|
|
28
|
+
]
|
|
29
|
+
},
|
|
30
|
+
"T_NHAB": {
|
|
31
|
+
"COLLECTED": 3
|
|
32
|
+
},
|
|
33
|
+
"T_SEXE": {
|
|
34
|
+
"COLLECTED": [
|
|
35
|
+
"1",
|
|
36
|
+
"1",
|
|
37
|
+
"1"
|
|
38
|
+
]
|
|
39
|
+
},
|
|
40
|
+
"T_STOC": {
|
|
41
|
+
"COLLECTED": "3"
|
|
42
|
+
},
|
|
43
|
+
"T_STOL": {
|
|
44
|
+
"COLLECTED": "2"
|
|
45
|
+
},
|
|
46
|
+
"T_LNAIS": {
|
|
47
|
+
"COLLECTED": [
|
|
48
|
+
"1",
|
|
49
|
+
"1",
|
|
50
|
+
"1"
|
|
51
|
+
]
|
|
52
|
+
},
|
|
53
|
+
"T_UNLOG": {
|
|
54
|
+
"COLLECTED": [
|
|
55
|
+
"2",
|
|
56
|
+
"2",
|
|
57
|
+
"2"
|
|
58
|
+
]
|
|
59
|
+
},
|
|
60
|
+
"DATE_ITW": {
|
|
61
|
+
"COLLECTED": "2027-03-01"
|
|
62
|
+
},
|
|
63
|
+
"T_PRENOM": {
|
|
64
|
+
"COLLECTED": [
|
|
65
|
+
"Lucas",
|
|
66
|
+
"Mathieu",
|
|
67
|
+
"Antoine"
|
|
68
|
+
]
|
|
69
|
+
},
|
|
70
|
+
"T_TYPLOG": {
|
|
71
|
+
"COLLECTED": "1"
|
|
72
|
+
},
|
|
73
|
+
"T_DEPNAIS": {
|
|
74
|
+
"COLLECTED": [
|
|
75
|
+
"Seine-Saint-Denis",
|
|
76
|
+
"Seine-et-Marne",
|
|
77
|
+
"Seine-Maritime"
|
|
78
|
+
]
|
|
79
|
+
},
|
|
80
|
+
"T_NATION1": {
|
|
81
|
+
"COLLECTED": [
|
|
82
|
+
true,
|
|
83
|
+
true,
|
|
84
|
+
true
|
|
85
|
+
]
|
|
86
|
+
},
|
|
87
|
+
"T_NPIECES": {
|
|
88
|
+
"COLLECTED": 5
|
|
89
|
+
},
|
|
90
|
+
"T_SURFACE": {
|
|
91
|
+
"COLLECTED": 98
|
|
92
|
+
},
|
|
93
|
+
"T_TYPMAIS": {
|
|
94
|
+
"COLLECTED": "2"
|
|
95
|
+
},
|
|
96
|
+
"T_DATENAIS": {
|
|
97
|
+
"COLLECTED": [
|
|
98
|
+
"1998-02-19",
|
|
99
|
+
"1997-06-03",
|
|
100
|
+
"1999-06-14"
|
|
101
|
+
]
|
|
102
|
+
},
|
|
103
|
+
"T_EMMENAGE": {
|
|
104
|
+
"COLLECTED": "2023"
|
|
105
|
+
},
|
|
106
|
+
"T_LOGPROPRI": {
|
|
107
|
+
"COLLECTED": "6"
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
},
|
|
111
|
+
"stateData": {
|
|
112
|
+
"state": "INIT",
|
|
113
|
+
"date": 1790865361892,
|
|
114
|
+
"currentPage": "1"
|
|
115
|
+
}
|
|
116
|
+
}
|