@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 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
4
|
+
const react_1 = require("@testing-library/react");
|
|
5
|
+
const vitest_1 = require("vitest");
|
|
6
|
+
const Suggester_1 = require("./Suggester"); // Ajuste le chemin selon ton projet
|
|
7
|
+
// Mock of useSuggestions
|
|
8
|
+
vitest_1.vi.mock('./useSuggestions', () => ({
|
|
9
|
+
useSuggestions: vitest_1.vi.fn(() => ({
|
|
10
|
+
state: 'success',
|
|
11
|
+
options: [],
|
|
12
|
+
search: '',
|
|
13
|
+
setSearch: vitest_1.vi.fn(),
|
|
14
|
+
onFocus: vitest_1.vi.fn(),
|
|
15
|
+
onBlur: vitest_1.vi.fn(),
|
|
16
|
+
})),
|
|
17
|
+
}));
|
|
18
|
+
// Mock of CustomSuggester
|
|
19
|
+
vitest_1.vi.mock('./CustomSuggester', () => ({
|
|
20
|
+
CustomSuggester: vitest_1.vi.fn(({ value }) => ((0, jsx_runtime_1.jsx)("div", { "data-testid": "custom-suggester", children: JSON.stringify(value) }))),
|
|
21
|
+
}));
|
|
22
|
+
(0, vitest_1.describe)('WrappedSuggester useEffect', () => {
|
|
23
|
+
(0, vitest_1.it)('should update selectedOptions when value prop changes', () => {
|
|
24
|
+
// Given initial props
|
|
25
|
+
const initialProps = {
|
|
26
|
+
storeName: 'store',
|
|
27
|
+
id: 'suggester-1',
|
|
28
|
+
className: '',
|
|
29
|
+
handleChanges: vitest_1.vi.fn(),
|
|
30
|
+
disabled: false,
|
|
31
|
+
value: 'initialValue',
|
|
32
|
+
label: 'Label',
|
|
33
|
+
declarations: [],
|
|
34
|
+
description: '',
|
|
35
|
+
errors: {},
|
|
36
|
+
readOnly: false,
|
|
37
|
+
response: { name: 'response' },
|
|
38
|
+
optionResponses: [{ name: 'labelResponse', attribute: 'label' }],
|
|
39
|
+
executeExpression: vitest_1.vi.fn(),
|
|
40
|
+
iteration: 1,
|
|
41
|
+
arbitrary: { response: { name: 'ARBITRARY' } },
|
|
42
|
+
optionRenderer: vitest_1.vi.fn(),
|
|
43
|
+
labelRenderer: vitest_1.vi.fn(),
|
|
44
|
+
focused: false,
|
|
45
|
+
};
|
|
46
|
+
// Given the composant initialize
|
|
47
|
+
const { rerender } = (0, react_1.render)((0, jsx_runtime_1.jsx)(Suggester_1.WrappedSuggester, { ...initialProps }));
|
|
48
|
+
const suggesterValue = react_1.screen.getByTestId('custom-suggester').textContent;
|
|
49
|
+
(0, vitest_1.expect)(suggesterValue).toContain('initialValue');
|
|
50
|
+
// When we change the value
|
|
51
|
+
const newProps = { ...initialProps, value: 'FORCED value' };
|
|
52
|
+
rerender((0, jsx_runtime_1.jsx)(Suggester_1.WrappedSuggester, { ...newProps }));
|
|
53
|
+
// Then selectedOptions, i.e value props of customSuggester have to be updated
|
|
54
|
+
const updatedValue = react_1.screen.getByTestId('custom-suggester').textContent;
|
|
55
|
+
(0, vitest_1.expect)(updatedValue).toContain('FORCED value');
|
|
56
|
+
});
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=Suggester.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Suggester.spec.js","sourceRoot":"","sources":["../../src/components/Suggester/Suggester.spec.tsx"],"names":[],"mappings":";;;AAAA,kDAAwD;AACxD,mCAAkD;AAClD,2CAA+C,CAAC,oCAAoC;AAEpF,yBAAyB;AACzB,WAAE,CAAC,IAAI,CAAC,kBAAkB,EAAE,GAAG,EAAE,CAAC,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AE,QAAQ,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE;YAC9C,cAAc,EAAE,WAAE,CAAC,EAAE,EAAE;YACvB,aAAa,EAAE,WAAE,CAAC,EAAE,EAAE;YACtB,OAAO,EAAE,KAAK;SACd,CAAC;QAEF,iCAAiC;QACjC,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAA,cAAM,EAAC,uBAAC,4BAAgB,OAAK,YAAY,GAAI,CAAC,CAAC;QACpE,MAAM,cAAc,GAAG,cAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC,WAAW,CAAC;QAC1E,IAAA,eAAM,EAAC,cAAc,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;QAEjD,2BAA2B;QAC3B,MAAM,QAAQ,GAAG,EAAE,GAAG,YAAY,EAAE,KAAK,EAAE,cAAc,EAAE,CAAC;QAC5D,QAAQ,CAAC,uBAAC,4BAAgB,OAAK,QAAQ,GAAI,CAAC,CAAC;QAE7C,8EAA8E;QAC9E,MAAM,YAAY,GAAG,cAAM,CAAC,WAAW,CAAC,kBAAkB,CAAC,CAAC,WAAW,CAAC;QACxE,IAAA,eAAM,EAAC,YAAY,CAAC,CAAC,SAAS,CAAC,cAAc,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
+
import { render, screen } from '@testing-library/react';
|
|
3
|
+
import { describe, it, expect, vi } from 'vitest';
|
|
4
|
+
import { WrappedSuggester } from './Suggester'; // Ajuste le chemin selon ton projet
|
|
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
|
+
// Mock of CustomSuggester
|
|
17
|
+
vi.mock('./CustomSuggester', () => ({
|
|
18
|
+
CustomSuggester: vi.fn(({ value }) => (_jsx("div", { "data-testid": "custom-suggester", children: JSON.stringify(value) }))),
|
|
19
|
+
}));
|
|
20
|
+
describe('WrappedSuggester useEffect', () => {
|
|
21
|
+
it('should update selectedOptions when value prop changes', () => {
|
|
22
|
+
// Given initial props
|
|
23
|
+
const initialProps = {
|
|
24
|
+
storeName: 'store',
|
|
25
|
+
id: 'suggester-1',
|
|
26
|
+
className: '',
|
|
27
|
+
handleChanges: vi.fn(),
|
|
28
|
+
disabled: false,
|
|
29
|
+
value: 'initialValue',
|
|
30
|
+
label: 'Label',
|
|
31
|
+
declarations: [],
|
|
32
|
+
description: '',
|
|
33
|
+
errors: {},
|
|
34
|
+
readOnly: false,
|
|
35
|
+
response: { name: 'response' },
|
|
36
|
+
optionResponses: [{ name: 'labelResponse', attribute: 'label' }],
|
|
37
|
+
executeExpression: vi.fn(),
|
|
38
|
+
iteration: 1,
|
|
39
|
+
arbitrary: { response: { name: 'ARBITRARY' } },
|
|
40
|
+
optionRenderer: vi.fn(),
|
|
41
|
+
labelRenderer: vi.fn(),
|
|
42
|
+
focused: false,
|
|
43
|
+
};
|
|
44
|
+
// Given the composant initialize
|
|
45
|
+
const { rerender } = render(_jsx(WrappedSuggester, { ...initialProps }));
|
|
46
|
+
const suggesterValue = screen.getByTestId('custom-suggester').textContent;
|
|
47
|
+
expect(suggesterValue).toContain('initialValue');
|
|
48
|
+
// When we change the value
|
|
49
|
+
const newProps = { ...initialProps, value: 'FORCED value' };
|
|
50
|
+
rerender(_jsx(WrappedSuggester, { ...newProps }));
|
|
51
|
+
// Then selectedOptions, i.e value props of customSuggester have to be updated
|
|
52
|
+
const updatedValue = screen.getByTestId('custom-suggester').textContent;
|
|
53
|
+
expect(updatedValue).toContain('FORCED value');
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
//# sourceMappingURL=Suggester.spec.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Suggester.spec.js","sourceRoot":"","sources":["../../../src/components/Suggester/Suggester.spec.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACxD,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAClD,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC,CAAC,oCAAoC;AAEpF,yBAAyB;AACzB,EAAE,CAAC,IAAI,CAAC,kBAAkB,EAAE,GAAG,EAAE,CAAC,CAAC;IAClC,cAAc,EAAE,EAAE,CAAC,EAAE,CAAC,GAAG,EAAE,CAAC,CAAC;QAC5B,KAAK,EAAE,SAAS;QAChB,OAAO,EAAE,EAAE;QACX,MAAM,EAAE,EAAE;QACV,SAAS,EAAE,EAAE,CAAC,EAAE,EAAE;QAClB,OAAO,EAAE,EAAE,CAAC,EAAE,EAAE;QAChB,MAAM,EAAE,EAAE,CAAC,EAAE,EAAE;KACf,CAAC,CAAC;CACH,CAAC,CAAC,CAAC;AAEJ,0BAA0B;AAC1B,EAAE,CAAC,IAAI,CAAC,mBAAmB,EAAE,GAAG,EAAE,CAAC,CAAC;IACnC,eAAe,EAAE,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,CACrC,6BAAiB,kBAAkB,YAAE,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,GAAO,CACjE,CAAC;CACF,CAAC,CAAC,CAAC;AAEJ,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IAC3C,EAAE,CAAC,uDAAuD,EAAE,GAAG,EAAE;QAChE,sBAAsB;QACtB,MAAM,YAAY,GAAG;YAC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CAAC,cAAc,CAAC,CAAC;IAChD,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/esm/type.source.d.ts
CHANGED
|
@@ -185,6 +185,15 @@ export type ComponentPairWiseLinksDefinition = ComponentDefinitionBase & {
|
|
|
185
185
|
[k: string]: string | null;
|
|
186
186
|
};
|
|
187
187
|
};
|
|
188
|
+
sourceVariables?: {
|
|
189
|
+
/** Name of the variable containing the name of the respondent */
|
|
190
|
+
name?: string;
|
|
191
|
+
/**
|
|
192
|
+
* Name of the variable containing the gender of the respondent
|
|
193
|
+
* (value of variable -> 1:male, 2: female)
|
|
194
|
+
*/
|
|
195
|
+
gender?: string;
|
|
196
|
+
};
|
|
188
197
|
components: ComponentDefinition[];
|
|
189
198
|
};
|
|
190
199
|
export type ComponentSummaryDefinition = ComponentDefinitionBase & {
|
|
@@ -1,22 +1,8 @@
|
|
|
1
|
-
import { fillComponentExpressions
|
|
1
|
+
import { fillComponentExpressions } from './fill-components/fill-component-expressions';
|
|
2
2
|
import { checkRoundaboutControl } from '../reducer/controls/check-roundabout-control';
|
|
3
3
|
import { checkBaseControl } from '../reducer/controls/check-base-control';
|
|
4
4
|
import { getComponentsFromState } from './get-components-from-state';
|
|
5
|
-
|
|
6
|
-
* Check if the component is a Loop or a RosterForLoop
|
|
7
|
-
*/
|
|
8
|
-
const isLoopComponent = (component) => {
|
|
9
|
-
return ['Loop', 'RosterForLoop'].includes(component.componentType);
|
|
10
|
-
};
|
|
11
|
-
/**
|
|
12
|
-
* Check if the component is a Roundabout
|
|
13
|
-
*/
|
|
14
|
-
const isRoundaboutComponent = (component) => {
|
|
15
|
-
return component.componentType === 'Roundabout';
|
|
16
|
-
};
|
|
17
|
-
const isQuestionComponent = (component) => {
|
|
18
|
-
return 'Question' === component.componentType;
|
|
19
|
-
};
|
|
5
|
+
import { isLoopComponent, isQuestionComponent, isRoundaboutComponent, } from './component';
|
|
20
6
|
/**
|
|
21
7
|
* Check if components of the current page have errors, and return a map of
|
|
22
8
|
* errors (indexed by component ID).
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"compile-controls.js","sourceRoot":"","sources":["../../../src/use-lunatic/commons/compile-controls.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"compile-controls.js","sourceRoot":"","sources":["../../../src/use-lunatic/commons/compile-controls.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,wBAAwB,EAAE,MAAM,8CAA8C,CAAC;AACxF,OAAO,EAAE,sBAAsB,EAAE,MAAM,8CAA8C,CAAC;AACtF,OAAO,EAAE,gBAAgB,EAAE,MAAM,wCAAwC,CAAC;AAC1E,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAC;AACrE,OAAO,EAGN,eAAe,EACf,mBAAmB,EACnB,qBAAqB,GAGrB,MAAM,aAAa,CAAC;AAOrB;;;GAGG;AACH,SAAS,eAAe,CACvB,KAAuB,EACvB,UAA0D,EAC1D,aAA8C;IAE9C,IAAI,MAAM,GAAG,aAAa,aAAb,aAAa,cAAb,aAAa,GAAK,EAAqC,CAAC;IAErE,KAAK,MAAM,SAAS,IAAI,UAAU,EAAE,CAAC;QACpC,0CAA0C;QAC1C,IAAI,UAAU,IAAI,SAAS,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,QAAQ,CAAC,EAAE,CAAC;YAClE,MAAM,eAAe,GAAG,aAAa,CACpC,SAAS,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,KAAK,CAAC,EAClD,KAAK,CAAC,iBAAiB,EACvB,KAAK,CAAC,KAAK,CACX,CAAC;YACF,IAAI,eAAe,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;gBAChC,MAAM,CAAC,SAAS,CAAC,EAAE,CAAC,GAAG,eAAe,CAAC;YACxC,CAAC;QACF,CAAC;QAED,kEAAkE;QAClE,IAAI,qBAAqB,CAAC,SAAS,CAAC;YACnC,MA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QAAQ,CACjC,CAAC;IACH,OAAO,aAAa,KAAK,SAAS,CAAC;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,eAAe,CAAC,KAAuB;IACtD,MAAM,UAAU,GAAG,sBAAsB,CAAC,KAAK,CAAC,CAAC;IACjD,MAAM,iBAAiB,GAAG,UAAU;SAClC,GAAG,CAAC,CAAC,SAAS,EAAE,EAAE,CAAC,wBAAwB,CAAC,SAAS,EAAE,KAAK,CAAC,CAAC;SAC9D,MAAM,CAAC,CAAC,SAAS,EAAE,EAAE;;QACrB,IAAI,iBAAiB,IAAI,SAAS,EAAE,CAAC;YACpC,OAAO,MAAA,SAAS,CAAC,eAAe,mCAAI,IAAI,CAAC;QAC1C,CAAC;QACD,OAAO,IAAI,CAAC;IACb,CAAC,CAAC,CAAC;IACJ,MAAM,MAAM,GAAG,eAAe,CAAC,KAAK,EAAE,iBAAiB,CAAC,CAAC;IACzD,MAAM,aAAa,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,SAAS,CAAC;IAC1E,OAAO;QACN,aAAa;QACb,UAAU,EAAE,gBAAgB,CAAC,aAAa,CAAC;KAC3C,CAAC;AACH,CAAC"}
|
|
@@ -1,10 +1,27 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { LunaticComponentDefinition } from '../type';
|
|
3
|
+
import { type DeepTranslateExpression } from './fill-components/fill-component-expressions';
|
|
4
|
+
export type ComponentDefinition = LunaticComponentDefinition;
|
|
5
|
+
export type InterpretedComponent = DeepTranslateExpression<LunaticComponentDefinition>;
|
|
6
|
+
export type InterpretedLoopComponent = DeepTranslateExpression<ComponentDefinition & {
|
|
7
|
+
componentType: 'Loop' | 'RosterForLoop';
|
|
8
|
+
}>;
|
|
9
|
+
export type InterpretedRoundaboutComponent = DeepTranslateExpression<ComponentDefinition & {
|
|
10
|
+
componentType: 'Roundabout';
|
|
11
|
+
}>;
|
|
12
|
+
export type InterpretedQuestionComponent = DeepTranslateExpression<ComponentDefinition & {
|
|
13
|
+
componentType: 'Question';
|
|
14
|
+
}>;
|
|
15
|
+
export type InterpretedPairwiseLinksComponent = DeepTranslateExpression<ComponentDefinition & {
|
|
16
|
+
componentType: 'PairwiseLinks';
|
|
17
|
+
}>;
|
|
18
|
+
/** Whether the component has a response attribute. */
|
|
3
19
|
export declare function hasResponse(component: unknown): component is {
|
|
4
20
|
response: {
|
|
5
21
|
name: string;
|
|
6
22
|
};
|
|
7
23
|
};
|
|
24
|
+
/** Whether the component has a responses attribute. */
|
|
8
25
|
export declare function hasResponses(component: unknown): component is {
|
|
9
26
|
responses?: Array<{
|
|
10
27
|
label: ReactNode;
|
|
@@ -14,9 +31,25 @@ export declare function hasResponses(component: unknown): component is {
|
|
|
14
31
|
};
|
|
15
32
|
}>;
|
|
16
33
|
};
|
|
34
|
+
/** Whether the component has a body attribute. */
|
|
17
35
|
export declare function hasBody(component: unknown): component is {
|
|
18
36
|
body: LunaticComponentDefinition<'Table'>['body'];
|
|
19
37
|
};
|
|
38
|
+
/** Whether the component has a componentType attribute. */
|
|
20
39
|
export declare function hasComponentType(component: unknown): component is {
|
|
21
40
|
componentType: string;
|
|
22
41
|
};
|
|
42
|
+
/** Whether the component is a Loop or a RosterForLoop. */
|
|
43
|
+
export declare function isLoopComponent(component: ComponentDefinition | InterpretedComponent): component is InterpretedLoopComponent;
|
|
44
|
+
/** Whether the component is a Roundabout. */
|
|
45
|
+
export declare function isRoundaboutComponent(component: ComponentDefinition | InterpretedComponent): component is InterpretedRoundaboutComponent;
|
|
46
|
+
/** Whether the component is a Question. */
|
|
47
|
+
export declare function isQuestionComponent(component: ComponentDefinition | InterpretedComponent): component is InterpretedQuestionComponent;
|
|
48
|
+
/** Whether the component is a PairwiseLinks. */
|
|
49
|
+
export declare function isPairwiseLinksComponent(component: ComponentDefinition | InterpretedComponent): component is InterpretedPairwiseLinksComponent;
|
|
50
|
+
/**
|
|
51
|
+
* Get the pairwise component if it exists.
|
|
52
|
+
*
|
|
53
|
+
* There should only be one so we return the first one we find.
|
|
54
|
+
*/
|
|
55
|
+
export declare function getPairwiseComponent(components: ComponentDefinition[]): InterpretedPairwiseLinksComponent | undefined;
|
|
@@ -1,22 +1,59 @@
|
|
|
1
|
+
/** Whether the component has a response attribute. */
|
|
1
2
|
export function hasResponse(component) {
|
|
2
3
|
return (!!component &&
|
|
3
4
|
typeof component === 'object' &&
|
|
4
5
|
'response' in component &&
|
|
5
6
|
'name' in component.response);
|
|
6
7
|
}
|
|
8
|
+
/** Whether the component has a responses attribute. */
|
|
7
9
|
export function hasResponses(component) {
|
|
8
10
|
return (!!component && typeof component === 'object' && 'responses' in component);
|
|
9
11
|
}
|
|
12
|
+
/** Whether the component has a body attribute. */
|
|
10
13
|
export function hasBody(component) {
|
|
11
14
|
return (!!component &&
|
|
12
15
|
typeof component === 'object' &&
|
|
13
16
|
'body' in component &&
|
|
14
17
|
Array.isArray(component.body));
|
|
15
18
|
}
|
|
19
|
+
/** Whether the component has a componentType attribute. */
|
|
16
20
|
export function hasComponentType(component) {
|
|
17
21
|
return (!!component &&
|
|
18
22
|
typeof component === 'object' &&
|
|
19
23
|
'componentType' in component &&
|
|
20
24
|
typeof component.componentType === 'string');
|
|
21
25
|
}
|
|
26
|
+
/** Whether the component is a Loop or a RosterForLoop. */
|
|
27
|
+
export function isLoopComponent(component) {
|
|
28
|
+
return ['Loop', 'RosterForLoop'].includes(component.componentType);
|
|
29
|
+
}
|
|
30
|
+
/** Whether the component is a Roundabout. */
|
|
31
|
+
export function isRoundaboutComponent(component) {
|
|
32
|
+
return component.componentType === 'Roundabout';
|
|
33
|
+
}
|
|
34
|
+
/** Whether the component is a Question. */
|
|
35
|
+
export function isQuestionComponent(component) {
|
|
36
|
+
return component.componentType === 'Question';
|
|
37
|
+
}
|
|
38
|
+
/** Whether the component is a PairwiseLinks. */
|
|
39
|
+
export function isPairwiseLinksComponent(component) {
|
|
40
|
+
return component.componentType === 'PairwiseLinks';
|
|
41
|
+
}
|
|
42
|
+
/**
|
|
43
|
+
* Get the pairwise component if it exists.
|
|
44
|
+
*
|
|
45
|
+
* There should only be one so we return the first one we find.
|
|
46
|
+
*/
|
|
47
|
+
export function getPairwiseComponent(components) {
|
|
48
|
+
for (const component of components) {
|
|
49
|
+
if (isPairwiseLinksComponent(component))
|
|
50
|
+
return component;
|
|
51
|
+
if (isQuestionComponent(component)) {
|
|
52
|
+
const childComponent = getPairwiseComponent(component.components);
|
|
53
|
+
if (childComponent)
|
|
54
|
+
return childComponent;
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
return undefined;
|
|
58
|
+
}
|
|
22
59
|
//# sourceMappingURL=component.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../src/use-lunatic/commons/component.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"component.js","sourceRoot":"","sources":["../../../src/use-lunatic/commons/component.ts"],"names":[],"mappings":"AA+BA,sDAAsD;AACtD,MAAM,UAAU,WAAW,CAC1B,SAAkB;IAElB,OAAO,CACN,CAAC,CAAC,SAAS;QACX,OAAO,SAAS,KAAK,QAAQ;QAC7B,UAAU,IAAI,SAAS;QACvB,MAAM,IAAK,SAAS,CAAC,QAAmB,CACxC,CAAC;AACH,CAAC;AAED,uDAAuD;AACvD,MAAM,UAAU,YAAY,CAAC,SAAkB;IAO9C,OAAO,CACN,CAAC,CAAC,SAAS,IAAI,OAAO,SAAS,KAAK,QAAQ,IAAI,WAAW,IAAI,SAAS,CACxE,CAAC;AACH,CAAC;AAED,kDAAkD;AAClD,MAAM,UAAU,OAAO,CAAC,SAAkB;IAGzC,OAAO,CACN,CAAC,CAAC,SAAS;QACX,OAAO,SAAS,KAAK,QAAQ;QAC7B,MAAM,IAAI,SAAS;QACnB,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,IAAI,CAAC,C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cleaning-behaviour.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"cleaning-behaviour.js","sourceRoot":"","sources":["../../../../../src/use-lunatic/commons/variables/behaviours/cleaning-behaviour.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAGlD;;;;;;;;GAQG;AACH,MAAM,UAAU,iBAAiB,CAChC,KAA4B,EAC5B,QAAmC,EACnC,eAAwC,EAAE;IAE1C,IAAI,CAAC,QAAQ,EAAE,CAAC;QACf,OAAO;IACR,CAAC;IAED,wDAAwD;IACxD,KAAK,MAAM,MAAM,IAAI,QAAQ,EAAE,CAAC;QAC/B,KAAK,MAAM,MAAM,IAAI,QAAQ,CAAC,MAAM,CAAC,EAAE,CAAC;YACvC,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC;gBAC7C,KAAK,MAAM,YAAY,IAAI,QAAQ,CAAC,MAAM,CAAC,CAAC,MAAM,CAAC,EAAE,CAAC;oBACrD,KAAK,CAAC,aAAa,CAClB,YAAY,CAAC,UAAU,EACvB,YAAY,CAAC,UAAU,EACvB;wBACC,SAAS,EAAE,YAAY,CAAC,SAAS;qBACjC,CACD,CAAC;gBACH,CAAC;YACF,CAAC;QACF,CAAC;IACF,CAAC;IAED,oDAAoD;IACpD,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEtD,KAAK,CAAC,EAAE,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE;QACxB,MAAM,YAAY,GAAG,WAAW,CAAC,GAAG,CAAC,CAAC,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACpD,MAAM,SAAS,GAAG,CAAC,CAAC,MAAM,CAAC,SAAS,CAAC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QACd,CAAC;QACD,yDAAyD;QACzD,IAAI,CAAC,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC;YACxB,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACzB,CAAC;QACD,uEAAuE;QACvE,OAAO,UAAU,CAAC,KAAK,EAAE,SAAS,EAAE,IAAI,CAAC,CAAC;IAC3C,CAAC,CAAC,CACF,CAAC;IACF,OAAO,IAAI,CAAC;AACb,CAAC"}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import { IterationLevel } from './models';
|
|
2
|
+
/** Special variable that will take the current iteration value. */
|
|
3
|
+
export declare const GLOBAL_ITERATION_INDEX = "GLOBAL_ITERATION_INDEX";
|
|
4
|
+
/** Manually compute the global iteration index from current iteration level. */
|
|
5
|
+
export declare function computeGlobalIterationIndexValue(iteration: IterationLevel): (string | number)[];
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/** Special variable that will take the current iteration value. */
|
|
2
|
+
export const GLOBAL_ITERATION_INDEX = 'GLOBAL_ITERATION_INDEX';
|
|
3
|
+
/** Manually compute the global iteration index from current iteration level. */
|
|
4
|
+
export function computeGlobalIterationIndexValue(iteration) {
|
|
5
|
+
return [GLOBAL_ITERATION_INDEX, iteration[0] + 1];
|
|
6
|
+
}
|
|
7
|
+
//# sourceMappingURL=global-variables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"global-variables.js","sourceRoot":"","sources":["../../../../src/use-lunatic/commons/variables/global-variables.ts"],"names":[],"mappings":"AAEA,mEAAmE;AACnE,MAAM,CAAC,MAAM,sBAAsB,GAAG,wBAAwB,CAAC;AAE/D,gFAAgF;AAChF,MAAM,UAAU,gCAAgC,CAAC,SAAyB;IACzE,OAAO,CAAC,sBAAsB,EAAE,SAAS,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;AACnD,CAAC"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { LunaticData, LunaticOptions, LunaticSource } from '../../type';
|
|
2
2
|
import type { RefObject } from 'react';
|
|
3
|
-
|
|
3
|
+
import { IterationLevel } from './models';
|
|
4
4
|
export type EventArgs = {
|
|
5
5
|
change: {
|
|
6
6
|
/** Name of the changed variable. */
|
|
@@ -35,7 +35,11 @@ export declare class LunaticVariablesStore {
|
|
|
35
35
|
autoCommit: boolean;
|
|
36
36
|
updatedAt: Timekey;
|
|
37
37
|
constructor();
|
|
38
|
-
static makeFromSource(source: LunaticSource, data: LunaticData,
|
|
38
|
+
static makeFromSource(source: LunaticSource, data: LunaticData, options?: {
|
|
39
|
+
changeHandler?: RefObject<LunaticOptions['onVariableChange']>;
|
|
40
|
+
disableCleaning?: boolean;
|
|
41
|
+
autoCommit?: boolean;
|
|
42
|
+
}): LunaticVariablesStore;
|
|
39
43
|
/**
|
|
40
44
|
* Create a new store from an object (useful for testing)
|
|
41
45
|
*/
|
|
@@ -65,6 +69,14 @@ export declare class LunaticVariablesStore {
|
|
|
65
69
|
shapeFrom?: string | string[];
|
|
66
70
|
dimension?: number;
|
|
67
71
|
}): LunaticVariable;
|
|
72
|
+
/**
|
|
73
|
+
* Register global variable
|
|
74
|
+
*/
|
|
75
|
+
setGlobal(name: string, { dependencies, globalDependencies, shapeFrom, }: {
|
|
76
|
+
dependencies?: string[];
|
|
77
|
+
globalDependencies?: Map<unknown, string>;
|
|
78
|
+
shapeFrom?: string | string[];
|
|
79
|
+
}): LunaticVariable;
|
|
68
80
|
/**
|
|
69
81
|
* Run a VTL expression
|
|
70
82
|
*/
|
|
@@ -84,7 +96,7 @@ export declare class LunaticVariablesStore {
|
|
|
84
96
|
get interpretCount(): number;
|
|
85
97
|
debug(): void;
|
|
86
98
|
}
|
|
87
|
-
declare class LunaticVariable {
|
|
99
|
+
export declare class LunaticVariable {
|
|
88
100
|
/** Last time the value was updated (changed). */
|
|
89
101
|
updatedAt: Map<string | undefined, number>;
|
|
90
102
|
/** Last time the store was updated (changed). */
|
|
@@ -95,8 +107,6 @@ declare class LunaticVariable {
|
|
|
95
107
|
private value;
|
|
96
108
|
/** List of direct dependencies, ex: ['FULLNAME', 'FIRSTNAME', 'LASTNAME']. */
|
|
97
109
|
private dependencies?;
|
|
98
|
-
/** List of deep dependencies, exploring the variables used in calculated variables, ex: ['FIRSTNAME', 'LASTNAME']. */
|
|
99
|
-
private baseDependencies?;
|
|
100
110
|
/** Expression for calculated variable. */
|
|
101
111
|
readonly expression?: string;
|
|
102
112
|
/** Dictionary holding all the available variables. */
|
|
@@ -105,6 +115,10 @@ declare class LunaticVariable {
|
|
|
105
115
|
private readonly iterationDepth?;
|
|
106
116
|
/** For calculated variable, shape is copied from another variable. */
|
|
107
117
|
private readonly shapeFrom?;
|
|
118
|
+
/** Whether this is a global variable with custom computation rules. */
|
|
119
|
+
private readonly isGlobal?;
|
|
120
|
+
/** Name of variables needed for global variables computation rules. */
|
|
121
|
+
private readonly globalDependencies?;
|
|
108
122
|
/** Keep a record of variable name (optional, used for debug). */
|
|
109
123
|
readonly name?: string;
|
|
110
124
|
/** Count the number of calculation. */
|
|
@@ -120,6 +134,8 @@ declare class LunaticVariable {
|
|
|
120
134
|
name?: string;
|
|
121
135
|
dimension?: number;
|
|
122
136
|
storeUpdatedAt: Timekey;
|
|
137
|
+
isGlobal?: boolean;
|
|
138
|
+
globalDependencies?: Map<unknown, string>;
|
|
123
139
|
});
|
|
124
140
|
getValue(iteration?: IterationLevel): unknown;
|
|
125
141
|
/**
|
|
@@ -132,10 +148,6 @@ declare class LunaticVariable {
|
|
|
132
148
|
private updateTimestamps;
|
|
133
149
|
private setValueForArray;
|
|
134
150
|
private getSavedValue;
|
|
135
|
-
/**
|
|
136
|
-
* Get a list of transitive dependencies (leaf of the dependency tree)
|
|
137
|
-
*/
|
|
138
|
-
private getBaseDependencies;
|
|
139
151
|
private getDependencies;
|
|
140
152
|
private getDependenciesValues;
|
|
141
153
|
/**
|