@inseefr/lunatic 3.7.7-rc.0 → 3.8.0-rc.0
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/Suggester/Suggester.spec.d.ts +1 -0
- package/components/Suggester/Suggester.spec.js +58 -0
- package/components/Suggester/Suggester.spec.js.map +1 -0
- package/esm/components/Suggester/Suggester.spec.d.ts +1 -0
- package/esm/components/Suggester/Suggester.spec.js +56 -0
- package/esm/components/Suggester/Suggester.spec.js.map +1 -0
- package/esm/type.source.d.ts +9 -0
- package/esm/use-lunatic/commons/compile-controls.js +2 -16
- package/esm/use-lunatic/commons/compile-controls.js.map +1 -1
- package/esm/use-lunatic/commons/component.d.ts +33 -0
- package/esm/use-lunatic/commons/component.js +37 -0
- package/esm/use-lunatic/commons/component.js.map +1 -1
- package/esm/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js.map +1 -1
- package/esm/use-lunatic/commons/variables/global-variables.d.ts +5 -0
- package/esm/use-lunatic/commons/variables/global-variables.js +7 -0
- package/esm/use-lunatic/commons/variables/global-variables.js.map +1 -0
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.d.ts +21 -9
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.js +67 -49
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.js.map +1 -1
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.spec.js +137 -6
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.spec.js.map +1 -1
- package/esm/use-lunatic/commons/variables/models.d.ts +1 -0
- package/esm/use-lunatic/commons/variables/models.js +2 -0
- package/esm/use-lunatic/commons/variables/models.js.map +1 -0
- package/esm/use-lunatic/commons/variables/pairwise-variables.d.ts +29 -0
- package/esm/use-lunatic/commons/variables/pairwise-variables.js +196 -0
- package/esm/use-lunatic/commons/variables/pairwise-variables.js.map +1 -0
- package/esm/use-lunatic/props/getComponentTypeProps.d.ts +1 -1
- package/esm/use-lunatic/reducer/reducerInitializer.js +5 -1
- package/esm/use-lunatic/reducer/reducerInitializer.js.map +1 -1
- package/package.json +30 -1
- package/src/components/Suggester/Suggester.spec.tsx +62 -0
- package/src/stories/pairwise/pairwise.stories.tsx +7 -0
- package/src/stories/pairwise/sourceGlobalVariables.json +337 -0
- package/src/type.source.ts +9 -0
- package/src/use-lunatic/commons/compile-controls.ts +10 -42
- package/src/use-lunatic/commons/component.ts +79 -0
- package/src/use-lunatic/commons/variables/behaviours/cleaning-behaviour.ts +2 -4
- package/src/use-lunatic/commons/variables/global-variables.ts +9 -0
- package/src/use-lunatic/commons/variables/lunatic-variables-store.spec.ts +149 -6
- package/src/use-lunatic/commons/variables/lunatic-variables-store.ts +113 -50
- package/src/use-lunatic/commons/variables/models.ts +1 -0
- package/src/use-lunatic/commons/variables/pairwise-variables.ts +251 -0
- package/src/use-lunatic/reducer/reducerInitializer.tsx +5 -7
- package/tsconfig.build.tsbuildinfo +1 -1
- package/type.source.d.ts +9 -0
- package/use-lunatic/commons/compile-controls.js +4 -18
- package/use-lunatic/commons/compile-controls.js.map +1 -1
- package/use-lunatic/commons/component.d.ts +33 -0
- package/use-lunatic/commons/component.js +42 -0
- package/use-lunatic/commons/component.js.map +1 -1
- package/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js.map +1 -1
- package/use-lunatic/commons/variables/global-variables.d.ts +5 -0
- package/use-lunatic/commons/variables/global-variables.js +11 -0
- package/use-lunatic/commons/variables/global-variables.js.map +1 -0
- package/use-lunatic/commons/variables/lunatic-variables-store.d.ts +21 -9
- package/use-lunatic/commons/variables/lunatic-variables-store.js +72 -50
- package/use-lunatic/commons/variables/lunatic-variables-store.js.map +1 -1
- package/use-lunatic/commons/variables/lunatic-variables-store.spec.js +137 -6
- package/use-lunatic/commons/variables/lunatic-variables-store.spec.js.map +1 -1
- package/use-lunatic/commons/variables/models.d.ts +1 -0
- package/use-lunatic/commons/variables/models.js +3 -0
- package/use-lunatic/commons/variables/models.js.map +1 -0
- package/use-lunatic/commons/variables/pairwise-variables.d.ts +29 -0
- package/use-lunatic/commons/variables/pairwise-variables.js +199 -0
- package/use-lunatic/commons/variables/pairwise-variables.js.map +1 -0
- package/use-lunatic/props/getComponentTypeProps.d.ts +1 -1
- package/use-lunatic/reducer/reducerInitializer.js +5 -1
- package/use-lunatic/reducer/reducerInitializer.js.map +1 -1
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { LunaticSource } from '../../type';
|
|
2
|
+
import { LunaticVariable } from './lunatic-variables-store';
|
|
3
|
+
import { IterationLevel } from './models';
|
|
4
|
+
/** Key used by the global dependencies map to store specific dependency. */
|
|
5
|
+
export declare enum PairwiseGlobalDependency {
|
|
6
|
+
Links = 0,
|
|
7
|
+
Name = 1,
|
|
8
|
+
Gender = 2
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* Manually setup the available pairwise global variables thanks to known
|
|
12
|
+
* business rules.
|
|
13
|
+
*
|
|
14
|
+
* The variables information (necessary for the setup) are only returned if
|
|
15
|
+
* there is a pairwise component in the provided source.
|
|
16
|
+
*/
|
|
17
|
+
export declare function computePairwiseGlobalVariables(source: LunaticSource): {
|
|
18
|
+
name: string;
|
|
19
|
+
dependencies: string[];
|
|
20
|
+
globalDependencies: Map<PairwiseGlobalDependency, string>;
|
|
21
|
+
shapeFrom?: string;
|
|
22
|
+
}[];
|
|
23
|
+
/**
|
|
24
|
+
* Compute the value of the pairwise global variable.
|
|
25
|
+
*
|
|
26
|
+
* It the variable name does not exist or if the value does not exist, it will
|
|
27
|
+
* return undefined.
|
|
28
|
+
*/
|
|
29
|
+
export declare function computePairwiseGlobalVariableValue(variableName: string, iteration: IterationLevel, globalDependencies: Map<PairwiseGlobalDependency, string>, dictionary: Map<string, LunaticVariable>): string | undefined;
|
|
@@ -0,0 +1,196 @@
|
|
|
1
|
+
/*
|
|
2
|
+
Global variables that are created when a pairwise component is present.
|
|
3
|
+
|
|
4
|
+
They can be used when creating the survey, so that filters can be made without
|
|
5
|
+
needing to make complex formula.
|
|
6
|
+
*/
|
|
7
|
+
import { getPairwiseComponent } from '../component';
|
|
8
|
+
/** Name of the first parent defined in the pairwise component. */
|
|
9
|
+
const GLOBAL_PARENT1_NAME = 'GLOBAL_PARENT1_PRENOM';
|
|
10
|
+
/**
|
|
11
|
+
* Gender of the first parent defined in the pairwise component:
|
|
12
|
+
* `"1"` = man, `"2"` = woman.
|
|
13
|
+
*/
|
|
14
|
+
const GLOBAL_PARENT1_GENDER = 'GLOBAL_PARENT1_SEXE';
|
|
15
|
+
/** Name of the second parent defined in the pairwise component. */
|
|
16
|
+
const GLOBAL_PARENT2_NAME = 'GLOBAL_PARENT2_PRENOM';
|
|
17
|
+
/**
|
|
18
|
+
* Gender of the second parent defined in the pairwise component:
|
|
19
|
+
* `"1"` = man, `"2"` = woman.
|
|
20
|
+
*/
|
|
21
|
+
const GLOBAL_PARENT2_GENDER = 'GLOBAL_PARENT2_SEXE';
|
|
22
|
+
/** Name of the partner defined in the pairwise component. */
|
|
23
|
+
const GLOBAL_PARTNER_NAME = 'GLOBAL_CONJOINT_PRENOM';
|
|
24
|
+
/**
|
|
25
|
+
* Names of the children defined in the pairwise component: the format is a
|
|
26
|
+
* string with ";" separating them.
|
|
27
|
+
*/
|
|
28
|
+
const GLOBAL_CHILDREN_NAMES = 'GLOBAL_ENFANTS_PRENOMS';
|
|
29
|
+
/**
|
|
30
|
+
* Pairwise links are defined by fixed values which represent a specific
|
|
31
|
+
* relationship type.
|
|
32
|
+
*/
|
|
33
|
+
var LinkType;
|
|
34
|
+
(function (LinkType) {
|
|
35
|
+
LinkType["Partner"] = "1";
|
|
36
|
+
LinkType["Parent"] = "2";
|
|
37
|
+
LinkType["Child"] = "3";
|
|
38
|
+
})(LinkType || (LinkType = {}));
|
|
39
|
+
/** Key used by the global dependencies map to store specific dependency. */
|
|
40
|
+
export var PairwiseGlobalDependency;
|
|
41
|
+
(function (PairwiseGlobalDependency) {
|
|
42
|
+
PairwiseGlobalDependency[PairwiseGlobalDependency["Links"] = 0] = "Links";
|
|
43
|
+
PairwiseGlobalDependency[PairwiseGlobalDependency["Name"] = 1] = "Name";
|
|
44
|
+
PairwiseGlobalDependency[PairwiseGlobalDependency["Gender"] = 2] = "Gender";
|
|
45
|
+
})(PairwiseGlobalDependency || (PairwiseGlobalDependency = {}));
|
|
46
|
+
/**
|
|
47
|
+
* Manually setup the available pairwise global variables thanks to known
|
|
48
|
+
* business rules.
|
|
49
|
+
*
|
|
50
|
+
* The variables information (necessary for the setup) are only returned if
|
|
51
|
+
* there is a pairwise component in the provided source.
|
|
52
|
+
*/
|
|
53
|
+
export function computePairwiseGlobalVariables(source) {
|
|
54
|
+
var _a, _b;
|
|
55
|
+
const component = getPairwiseComponent(source.components);
|
|
56
|
+
// There is not pairwise component, no need to initialize the variables.
|
|
57
|
+
if (!component)
|
|
58
|
+
return [];
|
|
59
|
+
const variables = [];
|
|
60
|
+
const pairwiseVariable = component.components[0].response.name;
|
|
61
|
+
const nameSourceVariable = (_a = component.sourceVariables) === null || _a === void 0 ? void 0 : _a.name;
|
|
62
|
+
const genderSourceVariable = (_b = component.sourceVariables) === null || _b === void 0 ? void 0 : _b.gender;
|
|
63
|
+
// Setup variables associated to the name.
|
|
64
|
+
if (nameSourceVariable) {
|
|
65
|
+
const globalDependencies = new Map();
|
|
66
|
+
globalDependencies.set(PairwiseGlobalDependency.Links, pairwiseVariable);
|
|
67
|
+
globalDependencies.set(PairwiseGlobalDependency.Name, nameSourceVariable);
|
|
68
|
+
const dependencies = [pairwiseVariable, nameSourceVariable];
|
|
69
|
+
variables.push({
|
|
70
|
+
name: GLOBAL_PARENT1_NAME,
|
|
71
|
+
dependencies,
|
|
72
|
+
globalDependencies,
|
|
73
|
+
shapeFrom: nameSourceVariable,
|
|
74
|
+
}, {
|
|
75
|
+
name: GLOBAL_PARENT2_NAME,
|
|
76
|
+
dependencies,
|
|
77
|
+
globalDependencies,
|
|
78
|
+
shapeFrom: nameSourceVariable,
|
|
79
|
+
}, {
|
|
80
|
+
name: GLOBAL_PARTNER_NAME,
|
|
81
|
+
dependencies,
|
|
82
|
+
globalDependencies,
|
|
83
|
+
shapeFrom: nameSourceVariable,
|
|
84
|
+
}, {
|
|
85
|
+
name: GLOBAL_CHILDREN_NAMES,
|
|
86
|
+
dependencies,
|
|
87
|
+
globalDependencies,
|
|
88
|
+
shapeFrom: nameSourceVariable,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
// Setup variables associated to the gender.
|
|
92
|
+
if (genderSourceVariable) {
|
|
93
|
+
const globalDependencies = new Map();
|
|
94
|
+
globalDependencies.set(PairwiseGlobalDependency.Links, pairwiseVariable);
|
|
95
|
+
globalDependencies.set(PairwiseGlobalDependency.Gender, genderSourceVariable);
|
|
96
|
+
const dependencies = [pairwiseVariable, genderSourceVariable];
|
|
97
|
+
variables.push({
|
|
98
|
+
name: GLOBAL_PARENT1_GENDER,
|
|
99
|
+
dependencies,
|
|
100
|
+
globalDependencies,
|
|
101
|
+
shapeFrom: nameSourceVariable,
|
|
102
|
+
}, {
|
|
103
|
+
name: GLOBAL_PARENT2_GENDER,
|
|
104
|
+
dependencies,
|
|
105
|
+
globalDependencies,
|
|
106
|
+
shapeFrom: nameSourceVariable,
|
|
107
|
+
});
|
|
108
|
+
}
|
|
109
|
+
return variables;
|
|
110
|
+
}
|
|
111
|
+
/**
|
|
112
|
+
* Compute the value of the pairwise global variable.
|
|
113
|
+
*
|
|
114
|
+
* It the variable name does not exist or if the value does not exist, it will
|
|
115
|
+
* return undefined.
|
|
116
|
+
*/
|
|
117
|
+
export function computePairwiseGlobalVariableValue(variableName, iteration, globalDependencies, dictionary) {
|
|
118
|
+
var _a, _b, _c;
|
|
119
|
+
// Get the values of the global dependencies we need
|
|
120
|
+
// (i.e. they exist in the map)
|
|
121
|
+
const linksVar = globalDependencies.get(PairwiseGlobalDependency.Links);
|
|
122
|
+
const links = linksVar ? (_a = dictionary === null || dictionary === void 0 ? void 0 : dictionary.get(linksVar)) === null || _a === void 0 ? void 0 : _a.getValue() : [[]];
|
|
123
|
+
const namesVar = globalDependencies.get(PairwiseGlobalDependency.Name);
|
|
124
|
+
const names = namesVar ? (_b = dictionary === null || dictionary === void 0 ? void 0 : dictionary.get(namesVar)) === null || _b === void 0 ? void 0 : _b.getValue() : [];
|
|
125
|
+
const gendersVar = globalDependencies.get(PairwiseGlobalDependency.Gender);
|
|
126
|
+
const genders = gendersVar ? (_c = dictionary === null || dictionary === void 0 ? void 0 : dictionary.get(gendersVar)) === null || _c === void 0 ? void 0 : _c.getValue() : [];
|
|
127
|
+
return computeVariableValue(variableName, iteration, {
|
|
128
|
+
genders: genders,
|
|
129
|
+
links: links,
|
|
130
|
+
names: names,
|
|
131
|
+
});
|
|
132
|
+
}
|
|
133
|
+
/** Compute the value of the pairwise global variable. */
|
|
134
|
+
function computeVariableValue(variableName, iteration, { genders = [], links = [[]], names = [], }) {
|
|
135
|
+
const idx = Array.isArray(iteration) ? iteration[0] : iteration;
|
|
136
|
+
const currentLinks = links[idx];
|
|
137
|
+
switch (variableName) {
|
|
138
|
+
case GLOBAL_PARENT1_NAME:
|
|
139
|
+
return computeParent1NameValue(currentLinks, names);
|
|
140
|
+
case GLOBAL_PARENT1_GENDER:
|
|
141
|
+
return computeParent1GenderValue(currentLinks, genders);
|
|
142
|
+
case GLOBAL_PARENT2_NAME:
|
|
143
|
+
return computeParent2NameValue(currentLinks, names);
|
|
144
|
+
case GLOBAL_PARENT2_GENDER:
|
|
145
|
+
return computeParent2GenderValue(currentLinks, genders);
|
|
146
|
+
case GLOBAL_PARTNER_NAME:
|
|
147
|
+
return computePartnerNameValue(currentLinks, names);
|
|
148
|
+
case GLOBAL_CHILDREN_NAMES:
|
|
149
|
+
return computeChildrenNamesValue(currentLinks, names);
|
|
150
|
+
default:
|
|
151
|
+
return undefined;
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
/** Get the index of the first parent found in pairwise links. */
|
|
155
|
+
function getFirstParentIndex(links) {
|
|
156
|
+
return links.indexOf(LinkType.Parent);
|
|
157
|
+
}
|
|
158
|
+
/** Get the index of the second parent found in pairwise links. */
|
|
159
|
+
function getSecondParentIndex(links) {
|
|
160
|
+
const firstParentIdx = links.indexOf(LinkType.Parent);
|
|
161
|
+
return links.indexOf(LinkType.Parent, firstParentIdx + 1);
|
|
162
|
+
}
|
|
163
|
+
/** Get the index of the first partner found in pairwise links. */
|
|
164
|
+
function getPartnerIndex(links) {
|
|
165
|
+
return links.indexOf(LinkType.Partner);
|
|
166
|
+
}
|
|
167
|
+
function computeParent1NameValue(links, names) {
|
|
168
|
+
const idx = getFirstParentIndex(links);
|
|
169
|
+
return idx === -1 ? undefined : names[idx];
|
|
170
|
+
}
|
|
171
|
+
function computeParent1GenderValue(links, genders) {
|
|
172
|
+
const idx = getFirstParentIndex(links);
|
|
173
|
+
return idx === -1 ? undefined : genders[idx];
|
|
174
|
+
}
|
|
175
|
+
function computeParent2NameValue(links, names) {
|
|
176
|
+
const idx = getSecondParentIndex(links);
|
|
177
|
+
return idx === -1 ? undefined : names[idx];
|
|
178
|
+
}
|
|
179
|
+
function computeParent2GenderValue(links, genders) {
|
|
180
|
+
const idx = getSecondParentIndex(links);
|
|
181
|
+
return idx === -1 ? undefined : genders[idx];
|
|
182
|
+
}
|
|
183
|
+
function computePartnerNameValue(links, names) {
|
|
184
|
+
const idx = getPartnerIndex(links);
|
|
185
|
+
return idx === -1 ? undefined : names[idx];
|
|
186
|
+
}
|
|
187
|
+
function computeChildrenNamesValue(links, names) {
|
|
188
|
+
const res = [];
|
|
189
|
+
for (let i = 0; i < links.length; i++) {
|
|
190
|
+
if (links[i] === LinkType.Child) {
|
|
191
|
+
res.push(names[i]);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
return res.length > 0 ? res.join(';') : undefined;
|
|
195
|
+
}
|
|
196
|
+
//# sourceMappingURL=pairwise-variables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"pairwise-variables.js","sourceRoot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GAAG,EAAE,CAAC;IACf,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE,CAAC;QACvC,IAAI,KAAK,CAAC,CAAC,CAAC,KAAK,QAAQ,CAAC,KAAK,EAAE,CAAC;YACjC,GAAG,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC;IACF,CAAC;IACD,OAAO,GAAG,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACnD,CAAC"}
|
|
@@ -187,7 +187,7 @@ export declare function getComponentTypeProps(component: DeepTranslateExpression
|
|
|
187
187
|
componentType?: "Dropdown";
|
|
188
188
|
} & {
|
|
189
189
|
conditionFilter?: boolean;
|
|
190
|
-
}) | (Pick<import("../../components/type").LunaticBaseProps<unknown>, "label" | "description" | "declarations" | "id" | "
|
|
190
|
+
}) | (Pick<import("../../components/type").LunaticBaseProps<unknown>, "label" | "description" | "declarations" | "id" | "disabled" | "shouldBeFiltered" | "propsTransformer" | "errors" | "readOnly"> & import("../..").LunaticExtraProps & {
|
|
191
191
|
components: import("../..").LunaticComponentProps[];
|
|
192
192
|
componentType?: "Question";
|
|
193
193
|
iteration?: number;
|
|
@@ -32,7 +32,11 @@ const baseState = {
|
|
|
32
32
|
const onChange = { current: () => { } };
|
|
33
33
|
export function reducerInitializer({ source, data, features = ['VTL'], initialPage = '1', lastReachedPage = undefined, withOverview = false, disableFilters = false, disableFiltersDescription = true, getReferentiel, onVariableChange = onChange, logger = console.error, }) {
|
|
34
34
|
var _a;
|
|
35
|
-
const variables = LunaticVariablesStore.makeFromSource(source, data,
|
|
35
|
+
const variables = LunaticVariablesStore.makeFromSource(source, data, {
|
|
36
|
+
autoCommit: source.pagination !== 'question',
|
|
37
|
+
changeHandler: onVariableChange,
|
|
38
|
+
disableCleaning: disableFilters,
|
|
39
|
+
});
|
|
36
40
|
const pages = checkLoops(createMapPages(source));
|
|
37
41
|
if (!source || !data) {
|
|
38
42
|
return baseState;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"reducerInitializer.js","sourceRoot":"","sources":["../../../src/use-lunatic/reducer/reducerInitializer.tsx"],"names":[],"mappings":";AAMA,OAAO,EAAE,qBAAqB,EAAE,MAAM,8CAA8C,CAAC;AACrF,OAAO,EAAE,UAAU,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AACxD,OAAO,EAAE,qBAAqB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAC3E,OAAO,EAAE,EAAE,EAAE,GAAG,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,OAAO,EAAE,MAAM,yCAAyC,CAAC;AAClE,OAAO,EAAE,mBAAmB,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAC1D,OAAO,EAAE,QAAQ,EAAE,MAAM,oBAAoB,CAAC;AAC9C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uCAAuC,CAAC;AAI3E,MAAM,SAAS,GAAG;IACjB,IAAI,EAAE,CAAC;IACP,OAAO,EAAE,CAAC;IACV,OAAO,EAAE,SAAS;IAClB,UAAU,EAAE,SAAS;IACrB,SAAS,EAAE,SAAS;IACpB,gBAAgB,EAAE,SAAS;IAC3B,YAAY,EAAE,SAAS;CACvB,CAAC;AACF,MAAM,SAAS,GAAG;IACjB,SAAS,EAAE,IAAI,qBAAqB,EAAE;IACtC,KAAK,EAAE,SAAS;IAChB,aAAa,EAAE,SAAS;IACxB,KAAK,EAAE,EAAE;IACT,QAAQ,EAAE,KAAK;IACf,SAAS,EAAE,IAAI,CAAC,GAAG,EAAE;IACrB,QAAQ,EAAE,EAAE;IACZ,cAAc,EAAE,GAAG,EAAE,GAAE,CAAC;IACxB,iBAAiB,EAAE,GAAO,EA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-rc.0",
|
|
4
4
|
"description": "Library of questionnaire components",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -86,6 +86,7 @@
|
|
|
86
86
|
"src/components/Subsequence/Subsequence.spec.tsx",
|
|
87
87
|
"src/components/Subsequence/Subsequence.tsx",
|
|
88
88
|
"src/components/Suggester/CustomSuggester.tsx",
|
|
89
|
+
"src/components/Suggester/Suggester.spec.tsx",
|
|
89
90
|
"src/components/Suggester/Suggester.tsx",
|
|
90
91
|
"src/components/Suggester/SuggesterNotification.tsx",
|
|
91
92
|
"src/components/Suggester/SuggesterType.ts",
|
|
@@ -302,6 +303,7 @@
|
|
|
302
303
|
"src/stories/loop/source-roster.json",
|
|
303
304
|
"src/stories/pairwise/pairwise.stories.tsx",
|
|
304
305
|
"src/stories/pairwise/source.json",
|
|
306
|
+
"src/stories/pairwise/sourceGlobalVariables.json",
|
|
305
307
|
"src/stories/paste.stories.tsx",
|
|
306
308
|
"src/stories/question/question.stories.tsx",
|
|
307
309
|
"src/stories/question/source.json",
|
|
@@ -386,8 +388,11 @@
|
|
|
386
388
|
"src/use-lunatic/commons/variables/behaviours/resizing-behaviour.ts",
|
|
387
389
|
"src/use-lunatic/commons/variables/errors.ts",
|
|
388
390
|
"src/use-lunatic/commons/variables/get-questionnaire-data.ts",
|
|
391
|
+
"src/use-lunatic/commons/variables/global-variables.ts",
|
|
389
392
|
"src/use-lunatic/commons/variables/lunatic-variables-store.spec.ts",
|
|
390
393
|
"src/use-lunatic/commons/variables/lunatic-variables-store.ts",
|
|
394
|
+
"src/use-lunatic/commons/variables/models.ts",
|
|
395
|
+
"src/use-lunatic/commons/variables/pairwise-variables.ts",
|
|
391
396
|
"src/use-lunatic/hooks/use-loop-variables.ts",
|
|
392
397
|
"src/use-lunatic/hooks/use-page-has-response.test.ts",
|
|
393
398
|
"src/use-lunatic/hooks/use-page-has-response.ts",
|
|
@@ -591,6 +596,9 @@
|
|
|
591
596
|
"components/Suggester/Suggester.d.ts",
|
|
592
597
|
"components/Suggester/Suggester.js",
|
|
593
598
|
"components/Suggester/Suggester.js.map",
|
|
599
|
+
"components/Suggester/Suggester.spec.d.ts",
|
|
600
|
+
"components/Suggester/Suggester.spec.js",
|
|
601
|
+
"components/Suggester/Suggester.spec.js.map",
|
|
594
602
|
"components/Suggester/SuggesterNotification.d.ts",
|
|
595
603
|
"components/Suggester/SuggesterNotification.js",
|
|
596
604
|
"components/Suggester/SuggesterNotification.js.map",
|
|
@@ -1017,6 +1025,9 @@
|
|
|
1017
1025
|
"esm/components/Suggester/Suggester.d.ts",
|
|
1018
1026
|
"esm/components/Suggester/Suggester.js",
|
|
1019
1027
|
"esm/components/Suggester/Suggester.js.map",
|
|
1028
|
+
"esm/components/Suggester/Suggester.spec.d.ts",
|
|
1029
|
+
"esm/components/Suggester/Suggester.spec.js",
|
|
1030
|
+
"esm/components/Suggester/Suggester.spec.js.map",
|
|
1020
1031
|
"esm/components/Suggester/SuggesterNotification.d.ts",
|
|
1021
1032
|
"esm/components/Suggester/SuggesterNotification.js",
|
|
1022
1033
|
"esm/components/Suggester/SuggesterNotification.js.map",
|
|
@@ -1448,12 +1459,21 @@
|
|
|
1448
1459
|
"esm/use-lunatic/commons/variables/get-questionnaire-data.d.ts",
|
|
1449
1460
|
"esm/use-lunatic/commons/variables/get-questionnaire-data.js",
|
|
1450
1461
|
"esm/use-lunatic/commons/variables/get-questionnaire-data.js.map",
|
|
1462
|
+
"esm/use-lunatic/commons/variables/global-variables.d.ts",
|
|
1463
|
+
"esm/use-lunatic/commons/variables/global-variables.js",
|
|
1464
|
+
"esm/use-lunatic/commons/variables/global-variables.js.map",
|
|
1451
1465
|
"esm/use-lunatic/commons/variables/lunatic-variables-store.d.ts",
|
|
1452
1466
|
"esm/use-lunatic/commons/variables/lunatic-variables-store.js",
|
|
1453
1467
|
"esm/use-lunatic/commons/variables/lunatic-variables-store.js.map",
|
|
1454
1468
|
"esm/use-lunatic/commons/variables/lunatic-variables-store.spec.d.ts",
|
|
1455
1469
|
"esm/use-lunatic/commons/variables/lunatic-variables-store.spec.js",
|
|
1456
1470
|
"esm/use-lunatic/commons/variables/lunatic-variables-store.spec.js.map",
|
|
1471
|
+
"esm/use-lunatic/commons/variables/models.d.ts",
|
|
1472
|
+
"esm/use-lunatic/commons/variables/models.js",
|
|
1473
|
+
"esm/use-lunatic/commons/variables/models.js.map",
|
|
1474
|
+
"esm/use-lunatic/commons/variables/pairwise-variables.d.ts",
|
|
1475
|
+
"esm/use-lunatic/commons/variables/pairwise-variables.js",
|
|
1476
|
+
"esm/use-lunatic/commons/variables/pairwise-variables.js.map",
|
|
1457
1477
|
"esm/use-lunatic/hooks/use-loop-variables.d.ts",
|
|
1458
1478
|
"esm/use-lunatic/hooks/use-loop-variables.js",
|
|
1459
1479
|
"esm/use-lunatic/hooks/use-loop-variables.js.map",
|
|
@@ -1781,12 +1801,21 @@
|
|
|
1781
1801
|
"use-lunatic/commons/variables/get-questionnaire-data.d.ts",
|
|
1782
1802
|
"use-lunatic/commons/variables/get-questionnaire-data.js",
|
|
1783
1803
|
"use-lunatic/commons/variables/get-questionnaire-data.js.map",
|
|
1804
|
+
"use-lunatic/commons/variables/global-variables.d.ts",
|
|
1805
|
+
"use-lunatic/commons/variables/global-variables.js",
|
|
1806
|
+
"use-lunatic/commons/variables/global-variables.js.map",
|
|
1784
1807
|
"use-lunatic/commons/variables/lunatic-variables-store.d.ts",
|
|
1785
1808
|
"use-lunatic/commons/variables/lunatic-variables-store.js",
|
|
1786
1809
|
"use-lunatic/commons/variables/lunatic-variables-store.js.map",
|
|
1787
1810
|
"use-lunatic/commons/variables/lunatic-variables-store.spec.d.ts",
|
|
1788
1811
|
"use-lunatic/commons/variables/lunatic-variables-store.spec.js",
|
|
1789
1812
|
"use-lunatic/commons/variables/lunatic-variables-store.spec.js.map",
|
|
1813
|
+
"use-lunatic/commons/variables/models.d.ts",
|
|
1814
|
+
"use-lunatic/commons/variables/models.js",
|
|
1815
|
+
"use-lunatic/commons/variables/models.js.map",
|
|
1816
|
+
"use-lunatic/commons/variables/pairwise-variables.d.ts",
|
|
1817
|
+
"use-lunatic/commons/variables/pairwise-variables.js",
|
|
1818
|
+
"use-lunatic/commons/variables/pairwise-variables.js.map",
|
|
1790
1819
|
"use-lunatic/hooks/use-loop-variables.d.ts",
|
|
1791
1820
|
"use-lunatic/hooks/use-loop-variables.js",
|
|
1792
1821
|
"use-lunatic/hooks/use-loop-variables.js.map",
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import { render, screen } from '@testing-library/react';
|
|
2
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
3
|
+
import { WrappedSuggester } from './Suggester'; // Ajuste le chemin selon ton projet
|
|
4
|
+
|
|
5
|
+
// Mock of useSuggestions
|
|
6
|
+
vi.mock('./useSuggestions', () => ({
|
|
7
|
+
useSuggestions: vi.fn(() => ({
|
|
8
|
+
state: 'success',
|
|
9
|
+
options: [],
|
|
10
|
+
search: '',
|
|
11
|
+
setSearch: vi.fn(),
|
|
12
|
+
onFocus: vi.fn(),
|
|
13
|
+
onBlur: vi.fn(),
|
|
14
|
+
})),
|
|
15
|
+
}));
|
|
16
|
+
|
|
17
|
+
// Mock of CustomSuggester
|
|
18
|
+
vi.mock('./CustomSuggester', () => ({
|
|
19
|
+
CustomSuggester: vi.fn(({ value }) => (
|
|
20
|
+
<div data-testid="custom-suggester">{JSON.stringify(value)}</div>
|
|
21
|
+
)),
|
|
22
|
+
}));
|
|
23
|
+
|
|
24
|
+
describe('WrappedSuggester useEffect', () => {
|
|
25
|
+
it('should update selectedOptions when value prop changes', () => {
|
|
26
|
+
// Given initial props
|
|
27
|
+
const initialProps = {
|
|
28
|
+
storeName: 'store',
|
|
29
|
+
id: 'suggester-1',
|
|
30
|
+
className: '',
|
|
31
|
+
handleChanges: vi.fn(),
|
|
32
|
+
disabled: false,
|
|
33
|
+
value: 'initialValue',
|
|
34
|
+
label: 'Label',
|
|
35
|
+
declarations: [],
|
|
36
|
+
description: '',
|
|
37
|
+
errors: {},
|
|
38
|
+
readOnly: false,
|
|
39
|
+
response: { name: 'response' },
|
|
40
|
+
optionResponses: [{ name: 'labelResponse', attribute: 'label' }],
|
|
41
|
+
executeExpression: vi.fn(),
|
|
42
|
+
iteration: 1,
|
|
43
|
+
arbitrary: { response: { name: 'ARBITRARY' } },
|
|
44
|
+
optionRenderer: vi.fn(),
|
|
45
|
+
labelRenderer: vi.fn(),
|
|
46
|
+
focused: false,
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// Given the composant initialize
|
|
50
|
+
const { rerender } = render(<WrappedSuggester {...initialProps} />);
|
|
51
|
+
const suggesterValue = screen.getByTestId('custom-suggester').textContent;
|
|
52
|
+
expect(suggesterValue).toContain('initialValue');
|
|
53
|
+
|
|
54
|
+
// When we change the value
|
|
55
|
+
const newProps = { ...initialProps, value: 'FORCED value' };
|
|
56
|
+
rerender(<WrappedSuggester {...newProps} />);
|
|
57
|
+
|
|
58
|
+
// Then selectedOptions, i.e value props of customSuggester have to be updated
|
|
59
|
+
const updatedValue = screen.getByTestId('custom-suggester').textContent;
|
|
60
|
+
expect(updatedValue).toContain('FORCED value');
|
|
61
|
+
});
|
|
62
|
+
});
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
type OrchestratorStory,
|
|
5
5
|
} from '../utils/Orchestrator';
|
|
6
6
|
import source from './source.json';
|
|
7
|
+
import sourceGlobalVariables from './sourceGlobalVariables.json';
|
|
7
8
|
|
|
8
9
|
import { Meta } from '@storybook/react';
|
|
9
10
|
|
|
@@ -28,3 +29,9 @@ export const Default: OrchestratorStory = {
|
|
|
28
29
|
initialPage: '3',
|
|
29
30
|
},
|
|
30
31
|
};
|
|
32
|
+
|
|
33
|
+
export const GlobalVariables: OrchestratorStory = {
|
|
34
|
+
args: {
|
|
35
|
+
source: sourceGlobalVariables,
|
|
36
|
+
},
|
|
37
|
+
};
|