@inseefr/lunatic 3.4.11-rc.0 → 3.5.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/Loop/Loop.js +7 -27
- package/components/Loop/Loop.js.map +1 -1
- package/components/RosterForLoop/RosterForLoop.js +8 -37
- package/components/RosterForLoop/RosterForLoop.js.map +1 -1
- package/components/Sequence/Sequence.d.ts +1 -1
- package/components/Subsequence/Subsequence.d.ts +1 -1
- package/components/library.d.ts +2 -2
- package/esm/components/Loop/Loop.js +7 -27
- package/esm/components/Loop/Loop.js.map +1 -1
- package/esm/components/RosterForLoop/RosterForLoop.js +8 -34
- package/esm/components/RosterForLoop/RosterForLoop.js.map +1 -1
- package/esm/components/Sequence/Sequence.d.ts +1 -1
- package/esm/components/Subsequence/Subsequence.d.ts +1 -1
- package/esm/components/library.d.ts +2 -2
- package/esm/hooks/useArticulation.d.ts +58 -0
- package/esm/hooks/useArticulation.js +81 -0
- package/esm/hooks/useArticulation.js.map +1 -0
- package/esm/i18n/dictionary.d.ts +0 -8
- package/esm/i18n/dictionary.js +0 -5
- package/esm/i18n/dictionary.js.map +1 -1
- package/esm/i18n/index.d.ts +1 -1
- package/esm/type.source.js +1 -0
- package/esm/type.source.js.map +1 -1
- package/esm/use-lunatic/commons/variables/behaviours/resizing-behaviour.js +7 -23
- package/esm/use-lunatic/commons/variables/behaviours/resizing-behaviour.js.map +1 -1
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.d.ts +1 -3
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.js +1 -1
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.js.map +1 -1
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.spec.js +1 -66
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.spec.js.map +1 -1
- package/esm/use-lunatic/props/getComponentTypeProps.d.ts +4 -4
- package/esm/use-lunatic/reducer/commons/index.d.ts +1 -0
- package/esm/use-lunatic/reducer/commons/index.js +1 -0
- package/esm/use-lunatic/reducer/commons/index.js.map +1 -1
- package/esm/use-lunatic/reducer/commons/resize-array-variable.d.ts +5 -0
- package/esm/use-lunatic/reducer/commons/resize-array-variable.js +21 -0
- package/esm/use-lunatic/reducer/commons/resize-array-variable.js.map +1 -0
- package/esm/use-lunatic/reducer/reducerInitializer.d.ts +2 -2
- package/esm/use-lunatic/reducer/reducerInitializer.js +31 -24
- package/esm/use-lunatic/reducer/reducerInitializer.js.map +1 -1
- package/esm/use-lunatic/type.d.ts +0 -1
- package/esm/utils/array.d.ts +0 -4
- package/esm/utils/array.js +2 -15
- package/esm/utils/array.js.map +1 -1
- package/esm/utils/array.spec.js +1 -12
- package/esm/utils/array.spec.js.map +1 -1
- package/hooks/useArticulation.d.ts +58 -0
- package/hooks/useArticulation.js +81 -0
- package/hooks/useArticulation.js.map +1 -0
- package/i18n/dictionary.d.ts +0 -8
- package/i18n/dictionary.js +0 -5
- package/i18n/dictionary.js.map +1 -1
- package/i18n/index.d.ts +1 -1
- package/package.json +20 -4
- package/src/components/Loop/Loop.tsx +12 -42
- package/src/components/RosterForLoop/RosterForLoop.tsx +2 -42
- package/src/components/RosterForLoop/__snapshots__/RosterForLoop.spec.tsx.snap +0 -18
- package/src/hooks/useArticulation.ts +124 -0
- package/src/i18n/dictionary.ts +0 -5
- package/src/stories/behaviour/articulation/articulation.stories.tsx +105 -0
- package/src/stories/behaviour/articulation/roundabout.json +348 -0
- package/src/stories/behaviour/performance/performance.stories.jsx +1 -1
- package/src/stories/pairwise/data.json +1 -1
- package/src/stories/pairwise/source.json +1 -3
- package/src/stories/utils/{SchemaValidator.jsx → SchemaValidator.tsx} +1 -1
- package/src/stories/utils/{orchestrator.jsx → orchestrator.tsx} +13 -9
- package/src/stories/utils/{overview.jsx → overview.tsx} +2 -0
- package/src/type.source.ts +1 -0
- package/src/use-lunatic/__snapshots__/use-lunatic.test.ts.snap +323 -0
- package/src/use-lunatic/commons/variables/behaviours/resizing-behaviour.ts +10 -35
- package/src/use-lunatic/commons/variables/lunatic-variables-store.spec.ts +1 -68
- package/src/use-lunatic/commons/variables/lunatic-variables-store.ts +2 -4
- package/src/use-lunatic/reducer/commons/index.ts +1 -0
- package/src/use-lunatic/reducer/commons/resize-array-variable.ts +28 -0
- package/src/use-lunatic/reducer/reducerInitializer.tsx +40 -29
- package/src/use-lunatic/type.ts +0 -1
- package/src/utils/array.spec.ts +1 -18
- package/src/utils/array.ts +3 -21
- package/tsconfig.build.tsbuildinfo +1 -1
- package/type.source.js +1 -0
- package/type.source.js.map +1 -1
- package/use-lunatic/commons/variables/behaviours/resizing-behaviour.js +6 -22
- package/use-lunatic/commons/variables/behaviours/resizing-behaviour.js.map +1 -1
- package/use-lunatic/commons/variables/lunatic-variables-store.d.ts +1 -3
- package/use-lunatic/commons/variables/lunatic-variables-store.js +1 -1
- package/use-lunatic/commons/variables/lunatic-variables-store.js.map +1 -1
- package/use-lunatic/commons/variables/lunatic-variables-store.spec.js +1 -66
- package/use-lunatic/commons/variables/lunatic-variables-store.spec.js.map +1 -1
- package/use-lunatic/props/getComponentTypeProps.d.ts +4 -4
- package/use-lunatic/reducer/commons/index.d.ts +1 -0
- package/use-lunatic/reducer/commons/index.js +6 -0
- package/use-lunatic/reducer/commons/index.js.map +1 -1
- package/use-lunatic/reducer/commons/resize-array-variable.d.ts +5 -0
- package/use-lunatic/reducer/commons/resize-array-variable.js +23 -0
- package/use-lunatic/reducer/commons/resize-array-variable.js.map +1 -0
- package/use-lunatic/reducer/reducerInitializer.d.ts +2 -2
- package/use-lunatic/reducer/reducerInitializer.js +31 -24
- package/use-lunatic/reducer/reducerInitializer.js.map +1 -1
- package/use-lunatic/type.d.ts +0 -1
- package/utils/array.d.ts +0 -4
- package/utils/array.js +2 -16
- package/utils/array.js.map +1 -1
- package/utils/array.spec.js +0 -11
- package/utils/array.spec.js.map +1 -1
package/esm/utils/array.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"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AAE,IAAI,GAAG,CAAC,CAAC,CAAC;AAChC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,WAAW,CAAI,GAAQ;IACtC,IAAI,OAAO,GAAG,GAAG,CAAC,CAAC,CAAC,CAAC;IACrB,IAAI,GAAG,GAAG,CAAC,CAAC,CAAC;IACb,KAAK,MAAM,IAAI,IAAI,GAAG,EAAE,CAAC;QACxB,IAAI,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,IAAI,CAAC,MAAM,GAAG,GAAG,EAAE,CAAC;YAC9C,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC;YAClB,OAAO,GAAG,IAAI,CAAC;QAChB,CAAC;QACD,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,CAAC,IAAI,GAAG,GAAG,CAAC,EAAE,CAAC;YACrC,OAAO,GAAG,IAAI,CAAC;QAChB,CAAC;IACF,CAAC;IACD,OAAO,OAAO,CAAC;AAChB,CAAC"}
|
package/esm/utils/array.spec.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { describe, it, expect } from 'vitest';
|
|
2
|
-
import { firstValueItem, resizeArray,
|
|
2
|
+
import { firstValueItem, resizeArray, setAtIndex } from './array';
|
|
3
3
|
describe('array', () => {
|
|
4
4
|
describe('resizeArray()', () => {
|
|
5
5
|
it('should append new value', () => {
|
|
@@ -38,16 +38,5 @@ describe('array', () => {
|
|
|
38
38
|
expect(firstValueItem([null, 1, 2])).toBe(1);
|
|
39
39
|
expect(firstValueItem([null, undefined, false])).toBe(false);
|
|
40
40
|
});
|
|
41
|
-
describe('resizeDownArrayWithIndex()', () => {
|
|
42
|
-
it('should remove an element of array', () => {
|
|
43
|
-
expect(resizeDownArrayWithIndex([1, 2, 3, 4], 2)).toEqual([1, 2, 4]);
|
|
44
|
-
expect(resizeDownArrayWithIndex([1, 2, 3, 4], 0)).toEqual([2, 3, 4]);
|
|
45
|
-
expect(resizeDownArrayWithIndex([1, 2, 3, 4], 3)).toEqual([1, 2, 3]);
|
|
46
|
-
});
|
|
47
|
-
it('should not remove element (out of index)', () => {
|
|
48
|
-
expect(resizeDownArrayWithIndex([1, 2, 3, 4], -1)).toEqual([1, 2, 3, 4]);
|
|
49
|
-
expect(resizeDownArrayWithIndex([1, 2, 3, 4], 4)).toEqual([1, 2, 3, 4]);
|
|
50
|
-
});
|
|
51
|
-
});
|
|
52
41
|
});
|
|
53
42
|
//# sourceMappingURL=array.spec.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.spec.js","sourceRoot":"","sources":["../../src/utils/array.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,
|
|
1
|
+
{"version":3,"file":"array.spec.js","sourceRoot":"","sources":["../../src/utils/array.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAC9C,OAAO,EAAE,cAAc,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,SAAS,CAAC;AAElE,QAAQ,CAAC,OAAO,EAAE,GAAG,EAAE;IACtB,QAAQ,CAAC,eAAe,EAAE,GAAG,EAAE;QAC9B,EAAE,CAAC,yBAAyB,EAAE,GAAG,EAAE;YAClC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YACrD,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACzD,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,qB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C;gBACV,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC;aACT,CAAC,CAAC;QACJ,CAAC,CAAC,CAAC;QACH,EAAE,CAAC,2CAA2C,EAAE,GAAG,EAAE;YACpD,MAAM,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,IAAI,EAAE,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC;QAC1E,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;IACH,EAAE,CAAC,gBAAgB,EAAE,GAAG,EAAE;QACzB,MAAM,CAAC,cAAc,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC1C,MAAM,CAAC,cAAc,CAAC,CAAC,IAAI,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QAC7C,MAAM,CAAC,cAAc,CAAC,CAAC,IAAI,EAAE,SAAS,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import type { LunaticSource } from '../type.source';
|
|
2
|
+
import type { LunaticData } from '../use-lunatic/type';
|
|
3
|
+
import { type ReactNode } from 'react';
|
|
4
|
+
type ArticulationItem = {
|
|
5
|
+
label: string;
|
|
6
|
+
value: string;
|
|
7
|
+
};
|
|
8
|
+
type Articulation = {
|
|
9
|
+
source: string;
|
|
10
|
+
items: ArticulationItem[];
|
|
11
|
+
};
|
|
12
|
+
type Item = {
|
|
13
|
+
cells: {
|
|
14
|
+
label: string;
|
|
15
|
+
value: ReactNode;
|
|
16
|
+
page?: string;
|
|
17
|
+
}[];
|
|
18
|
+
progress: number;
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Hook to get articulation state
|
|
22
|
+
*
|
|
23
|
+
* ## Why this hook
|
|
24
|
+
*
|
|
25
|
+
* The goal of this hook is to provide insights about a roundabout using extra information inserted in the JSON source
|
|
26
|
+
* provided to Lunatic.
|
|
27
|
+
*
|
|
28
|
+
* For instance
|
|
29
|
+
*
|
|
30
|
+
* ```
|
|
31
|
+
* "articulation": {
|
|
32
|
+
* "source": "roundabout",
|
|
33
|
+
* "items": [
|
|
34
|
+
* {
|
|
35
|
+
* "label": "Prénom",
|
|
36
|
+
* "value": "PRENOMS"
|
|
37
|
+
* },
|
|
38
|
+
* {
|
|
39
|
+
* "label": "Sexe",
|
|
40
|
+
* "value": "if SEXE = \"H\" then \"Homme\" else \"Femme\""
|
|
41
|
+
* },
|
|
42
|
+
* {
|
|
43
|
+
* "label": "Age",
|
|
44
|
+
* "value": "cast(AGE, string) || \" ans\""
|
|
45
|
+
* }
|
|
46
|
+
* ]
|
|
47
|
+
* },
|
|
48
|
+
* ```
|
|
49
|
+
*
|
|
50
|
+
* - source is the ID of the roundabout component
|
|
51
|
+
* - items define the field to extract from the roundabout data
|
|
52
|
+
*/
|
|
53
|
+
export declare function useArticulation(source: LunaticSource & {
|
|
54
|
+
articulation: Articulation;
|
|
55
|
+
}, data: LunaticData): {
|
|
56
|
+
items: Item[];
|
|
57
|
+
};
|
|
58
|
+
export {};
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useArticulation = useArticulation;
|
|
4
|
+
const reducerInitializer_1 = require("../use-lunatic/reducer/reducerInitializer");
|
|
5
|
+
const react_1 = require("react");
|
|
6
|
+
const array_1 = require("../utils/array");
|
|
7
|
+
const number_1 = require("../utils/number");
|
|
8
|
+
/**
|
|
9
|
+
* Hook to get articulation state
|
|
10
|
+
*
|
|
11
|
+
* ## Why this hook
|
|
12
|
+
*
|
|
13
|
+
* The goal of this hook is to provide insights about a roundabout using extra information inserted in the JSON source
|
|
14
|
+
* provided to Lunatic.
|
|
15
|
+
*
|
|
16
|
+
* For instance
|
|
17
|
+
*
|
|
18
|
+
* ```
|
|
19
|
+
* "articulation": {
|
|
20
|
+
* "source": "roundabout",
|
|
21
|
+
* "items": [
|
|
22
|
+
* {
|
|
23
|
+
* "label": "Prénom",
|
|
24
|
+
* "value": "PRENOMS"
|
|
25
|
+
* },
|
|
26
|
+
* {
|
|
27
|
+
* "label": "Sexe",
|
|
28
|
+
* "value": "if SEXE = \"H\" then \"Homme\" else \"Femme\""
|
|
29
|
+
* },
|
|
30
|
+
* {
|
|
31
|
+
* "label": "Age",
|
|
32
|
+
* "value": "cast(AGE, string) || \" ans\""
|
|
33
|
+
* }
|
|
34
|
+
* ]
|
|
35
|
+
* },
|
|
36
|
+
* ```
|
|
37
|
+
*
|
|
38
|
+
* - source is the ID of the roundabout component
|
|
39
|
+
* - items define the field to extract from the roundabout data
|
|
40
|
+
*/
|
|
41
|
+
function useArticulation(source, data) {
|
|
42
|
+
const roundabout = (0, react_1.useMemo)(() => findComponentById(source.components, source.articulation.source), [source]);
|
|
43
|
+
const { variables } = (0, react_1.useMemo)(() => (0, reducerInitializer_1.reducerInitializer)({ source, data }), [source, data]);
|
|
44
|
+
const iterations = (0, react_1.useMemo)(() => (0, number_1.forceInt)(variables.run(roundabout?.iterations.value ?? '0')),
|
|
45
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46
|
+
[source, data]);
|
|
47
|
+
const rows = (0, react_1.useMemo)(() => {
|
|
48
|
+
return (0, array_1.times)(iterations, (k) => source.articulation.items.map((item) => ({
|
|
49
|
+
label: item.label,
|
|
50
|
+
value: variables.run(item.value, { iteration: [k] }),
|
|
51
|
+
})));
|
|
52
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
53
|
+
}, [source, data, iterations, roundabout?.progressVariable]);
|
|
54
|
+
if (!roundabout) {
|
|
55
|
+
return {
|
|
56
|
+
items: [],
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
return {
|
|
60
|
+
items: rows.map((row, k) => ({
|
|
61
|
+
cells: row,
|
|
62
|
+
progress: (0, number_1.forceInt)(variables.get(roundabout.progressVariable, [k]) ?? -1),
|
|
63
|
+
page: roundabout.page ? `${roundabout.page}.1#${k + 1}` : '1',
|
|
64
|
+
})),
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
function findComponentById(components, id) {
|
|
68
|
+
for (const c of components) {
|
|
69
|
+
if ('id' in c && c.id === id && c.componentType === 'Roundabout') {
|
|
70
|
+
return c;
|
|
71
|
+
}
|
|
72
|
+
if ('components' in c) {
|
|
73
|
+
const child = findComponentById(c.components, id);
|
|
74
|
+
if (child) {
|
|
75
|
+
return child;
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=useArticulation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"useArticulation.js","sourceRoot":"","sources":["../src/hooks/useArticulation.ts"],"names":[],"mappings":";;AA+DA,0CA0CC;AAnGD,kFAA+E;AAC/E,iCAAgD;AAChD,0CAAuC;AACvC,4CAA2C;AAqB3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,SAAgB,eAAe,CAC9B,MAAsD,EACtD,IAAiB;IAEjB,MAAM,UAAU,GAAG,IAAA,eAAO,EACzB,GAAG,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,EACtE,CAAC,MAAM,CAAC,CACR,CAAC;IACF,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,eAAO,EAC5B,GAAG,EAAE,CAAC,IAAA,uCAAkB,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC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AAE,CAAC,CAAC,CAAC,GAAG;SAC7D,CAAC,CAAC;KACH,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CACzB,UAAiC,EACjC,EAAU;IAEV,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;QAC5B,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,aAAa,KAAK,YAAY,EAAE,CAAC;YAClE,OAAO,CAAC,CAAC;QACV,CAAC;QACD,IAAI,YAAY,IAAI,CAAC,EAAE,CAAC;YACvB,MAAM,KAAK,GAAG,iBAAiB,CAAC,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;YAClD,IAAI,KAAK,EAAE,CAAC;gBACX,OAAO,KAAK,CAAC;YACd,CAAC;QACF,CAAC;IACF,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC"}
|
package/i18n/dictionary.d.ts
CHANGED
|
@@ -7,14 +7,6 @@ declare const dictionary: {
|
|
|
7
7
|
readonly fr: "Supprimer une ligne";
|
|
8
8
|
readonly en: "Remove row";
|
|
9
9
|
};
|
|
10
|
-
readonly DEFAULT_BUTTON_REMOVE_THAT_ROW: {
|
|
11
|
-
readonly fr: "Supprimer cette ligne";
|
|
12
|
-
readonly en: "Remove that row";
|
|
13
|
-
};
|
|
14
|
-
readonly ACTION_HEADER: {
|
|
15
|
-
readonly fr: "Action";
|
|
16
|
-
readonly en: "Action";
|
|
17
|
-
};
|
|
18
10
|
readonly MODAL_IGNORE: {
|
|
19
11
|
readonly fr: "Poursuivre";
|
|
20
12
|
readonly en: "Ignore";
|
package/i18n/dictionary.js
CHANGED
|
@@ -3,11 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
const dictionary = {
|
|
4
4
|
DEFAULT_BUTTON_ADD: { fr: 'Ajouter une ligne', en: 'Add row' },
|
|
5
5
|
DEFAULT_BUTTON_REMOVE: { fr: 'Supprimer une ligne', en: 'Remove row' },
|
|
6
|
-
DEFAULT_BUTTON_REMOVE_THAT_ROW: {
|
|
7
|
-
fr: 'Supprimer cette ligne',
|
|
8
|
-
en: 'Remove that row',
|
|
9
|
-
},
|
|
10
|
-
ACTION_HEADER: { fr: 'Action', en: 'Action' },
|
|
11
6
|
MODAL_IGNORE: { fr: 'Poursuivre', en: 'Ignore' },
|
|
12
7
|
MODAL_CORRECT: { fr: 'Corriger ma réponse', en: 'Correct' },
|
|
13
8
|
DK: { fr: 'Ne sais pas', en: "Don't know" },
|
package/i18n/dictionary.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dictionary.js","sourceRoot":"","sources":["../src/i18n/dictionary.ts"],"names":[],"mappings":";;AAAA,MAAM,UAAU,GAAG;IAClB,kBAAkB,EAAE,EAAE,EAAE,EAAE,mBAAmB,EAAE,EAAE,EAAE,SAAS,EAAE;IAC9D,qBAAqB,EAAE,EAAE,EAAE,EAAE,qBAAqB,EAAE,EAAE,EAAE,YAAY,EAAE;IACtE,
|
|
1
|
+
{"version":3,"file":"dictionary.js","sourceRoot":"","sources":["../src/i18n/dictionary.ts"],"names":[],"mappings":";;AAAA,MAAM,UAAU,GAAG;IAClB,kBAAkB,EAAE,EAAE,EAAE,EAAE,mBAAmB,EAAE,EAAE,EAAE,SAAS,EAAE;IAC9D,qBAAqB,EAAE,EAAE,EAAE,EAAE,qBAAqB,EAAE,EAAE,EAAE,YAAY,EAAE;IACtE,YAAY,EAAE,EAAE,EAAE,EAAE,YAAY,EAAE,EAAE,EAAE,QAAQ,EAAE;IAChD,aAAa,EAAE,EAAE,EAAE,EAAE,qBAAqB,EAAE,EAAE,EAAE,SAAS,EAAE;IAC3D,EAAE,EAAE,EAAE,EAAE,EAAE,aAAa,EAAE,EAAE,EAAE,YAAY,EAAE;IAC3C,EAAE,EAAE,EAAE,EAAE,EAAE,OAAO,EAAE,EAAE,EAAE,SAAS,EAAE;IAClC,WAAW,EAAE,EAAE,EAAE,EAAE,2BAA2B,EAAE,EAAE,EAAE,iBAAiB,EAAE;IACvE,iBAAiB,EAAE;QAClB,EAAE,EAAE,8BAA8B;QAClC,EAAE,EAAE,iBAAiB;KACrB;IACD,mBAAmB,EAAE;QACpB,EAAE,EAAE,uBAAuB;QAC3B,EAAE,EAAE,YAAY;KAChB;IACD,eAAe,EAAE;QAChB,EAAE,EAAE,uCAAuC;QAC3C,EAAE,EAAE,6CAA6C;KACjD;IACD,mBAAmB,EAAE;QACpB,EAAE,EAAE,SAAS;QACb,EAAE,EAAE,QAAQ;KACZ;CACQ,CAAC;AAEX,kBAAe,UAAU,CAAC"}
|
package/i18n/index.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export declare const inputNumberPropsI18N: {
|
|
|
3
3
|
thousandSeparator: string;
|
|
4
4
|
decimalSeparator: string;
|
|
5
5
|
};
|
|
6
|
-
declare const _default: Record<"DK" | "RF" | "DEFAULT_BUTTON_ADD" | "DEFAULT_BUTTON_REMOVE" | "
|
|
6
|
+
declare const _default: Record<"DK" | "RF" | "DEFAULT_BUTTON_ADD" | "DEFAULT_BUTTON_REMOVE" | "MODAL_IGNORE" | "MODAL_CORRECT" | "PLACEHOLDER" | "SUGGESTER_LOADING" | "SUGGESTER_NO_RESULT" | "SUGGESTER_ERROR" | "SUGGESTER_ARBITRARY", string>;
|
|
7
7
|
export default _default;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inseefr/lunatic",
|
|
3
|
-
"version": "3.
|
|
3
|
+
"version": "3.5.0-rc.0",
|
|
4
4
|
"description": "Library of questionnaire components",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -219,6 +219,7 @@
|
|
|
219
219
|
"src/hooks/use-auto-focus.ts",
|
|
220
220
|
"src/hooks/use-track-changes.ts",
|
|
221
221
|
"src/hooks/use-why-render.ts",
|
|
222
|
+
"src/hooks/useArticulation.ts",
|
|
222
223
|
"src/hooks/useDebounce.ts",
|
|
223
224
|
"src/hooks/useDocumentEvent.ts",
|
|
224
225
|
"src/hooks/useKeyboardKey.ts",
|
|
@@ -232,6 +233,8 @@
|
|
|
232
233
|
"src/insee.d.ts",
|
|
233
234
|
"src/stories/accordion/accordion.stories.jsx",
|
|
234
235
|
"src/stories/accordion/source.json",
|
|
236
|
+
"src/stories/behaviour/articulation/articulation.stories.tsx",
|
|
237
|
+
"src/stories/behaviour/articulation/roundabout.json",
|
|
235
238
|
"src/stories/behaviour/cleaning/cleaning.stories.jsx",
|
|
236
239
|
"src/stories/behaviour/cleaning/source-loop.json",
|
|
237
240
|
"src/stories/behaviour/cleaning/source.json",
|
|
@@ -366,15 +369,15 @@
|
|
|
366
369
|
"src/stories/textarea/data.json",
|
|
367
370
|
"src/stories/textarea/source.json",
|
|
368
371
|
"src/stories/textarea/textarea.stories.jsx",
|
|
369
|
-
"src/stories/utils/SchemaValidator.
|
|
372
|
+
"src/stories/utils/SchemaValidator.tsx",
|
|
370
373
|
"src/stories/utils/custom-lunatic.scss",
|
|
371
374
|
"src/stories/utils/default-arg-types.js",
|
|
372
375
|
"src/stories/utils/default-args.js",
|
|
373
376
|
"src/stories/utils/options.js",
|
|
374
|
-
"src/stories/utils/orchestrator.jsx",
|
|
375
377
|
"src/stories/utils/orchestrator.scss",
|
|
376
|
-
"src/stories/utils/
|
|
378
|
+
"src/stories/utils/orchestrator.tsx",
|
|
377
379
|
"src/stories/utils/overview.scss",
|
|
380
|
+
"src/stories/utils/overview.tsx",
|
|
378
381
|
"src/stories/utils/referentiel.js",
|
|
379
382
|
"src/test.d.ts",
|
|
380
383
|
"src/tests/setup.ts",
|
|
@@ -428,6 +431,7 @@
|
|
|
428
431
|
"src/use-lunatic/props/propValue.ts",
|
|
429
432
|
"src/use-lunatic/reducer/commons/auto-explore-loop.ts",
|
|
430
433
|
"src/use-lunatic/reducer/commons/index.ts",
|
|
434
|
+
"src/use-lunatic/reducer/commons/resize-array-variable.ts",
|
|
431
435
|
"src/use-lunatic/reducer/commons/validate-condition-filter.ts",
|
|
432
436
|
"src/use-lunatic/reducer/controls/check-base-control.ts",
|
|
433
437
|
"src/use-lunatic/reducer/controls/check-roundabout-control.ts",
|
|
@@ -1345,6 +1349,9 @@
|
|
|
1345
1349
|
"esm/hooks/use-why-render.d.ts",
|
|
1346
1350
|
"esm/hooks/use-why-render.js",
|
|
1347
1351
|
"esm/hooks/use-why-render.js.map",
|
|
1352
|
+
"esm/hooks/useArticulation.d.ts",
|
|
1353
|
+
"esm/hooks/useArticulation.js",
|
|
1354
|
+
"esm/hooks/useArticulation.js.map",
|
|
1348
1355
|
"esm/hooks/useDebounce.d.ts",
|
|
1349
1356
|
"esm/hooks/useDebounce.js",
|
|
1350
1357
|
"esm/hooks/useDebounce.js.map",
|
|
@@ -1527,6 +1534,9 @@
|
|
|
1527
1534
|
"esm/use-lunatic/reducer/commons/index.d.ts",
|
|
1528
1535
|
"esm/use-lunatic/reducer/commons/index.js",
|
|
1529
1536
|
"esm/use-lunatic/reducer/commons/index.js.map",
|
|
1537
|
+
"esm/use-lunatic/reducer/commons/resize-array-variable.d.ts",
|
|
1538
|
+
"esm/use-lunatic/reducer/commons/resize-array-variable.js",
|
|
1539
|
+
"esm/use-lunatic/reducer/commons/resize-array-variable.js.map",
|
|
1530
1540
|
"esm/use-lunatic/reducer/commons/validate-condition-filter.d.ts",
|
|
1531
1541
|
"esm/use-lunatic/reducer/commons/validate-condition-filter.js",
|
|
1532
1542
|
"esm/use-lunatic/reducer/commons/validate-condition-filter.js.map",
|
|
@@ -1665,6 +1675,9 @@
|
|
|
1665
1675
|
"hooks/use-why-render.d.ts",
|
|
1666
1676
|
"hooks/use-why-render.js",
|
|
1667
1677
|
"hooks/use-why-render.js.map",
|
|
1678
|
+
"hooks/useArticulation.d.ts",
|
|
1679
|
+
"hooks/useArticulation.js",
|
|
1680
|
+
"hooks/useArticulation.js.map",
|
|
1668
1681
|
"hooks/useDebounce.d.ts",
|
|
1669
1682
|
"hooks/useDebounce.js",
|
|
1670
1683
|
"hooks/useDebounce.js.map",
|
|
@@ -1848,6 +1861,9 @@
|
|
|
1848
1861
|
"use-lunatic/reducer/commons/index.d.ts",
|
|
1849
1862
|
"use-lunatic/reducer/commons/index.js",
|
|
1850
1863
|
"use-lunatic/reducer/commons/index.js.map",
|
|
1864
|
+
"use-lunatic/reducer/commons/resize-array-variable.d.ts",
|
|
1865
|
+
"use-lunatic/reducer/commons/resize-array-variable.js",
|
|
1866
|
+
"use-lunatic/reducer/commons/resize-array-variable.js.map",
|
|
1851
1867
|
"use-lunatic/reducer/commons/validate-condition-filter.d.ts",
|
|
1852
1868
|
"use-lunatic/reducer/commons/validate-condition-filter.js",
|
|
1853
1869
|
"use-lunatic/reducer/commons/validate-condition-filter.js.map",
|
|
@@ -51,30 +51,6 @@ export function Loop({
|
|
|
51
51
|
}
|
|
52
52
|
}, [nbRows, handleChanges, value]);
|
|
53
53
|
|
|
54
|
-
const removeRowWithIndex = useCallback(
|
|
55
|
-
(indexToRemove: number) => {
|
|
56
|
-
if (nbRows <= min) {
|
|
57
|
-
return;
|
|
58
|
-
}
|
|
59
|
-
/**
|
|
60
|
-
* Case 0: trying to delete
|
|
61
|
-
*/
|
|
62
|
-
if (indexToRemove >= nbRows || indexToRemove < 0) {
|
|
63
|
-
return;
|
|
64
|
-
}
|
|
65
|
-
const newResponses = Object.entries(value).map(([k, v]) => {
|
|
66
|
-
return {
|
|
67
|
-
name: k,
|
|
68
|
-
value: v?.filter((_, i) => i !== indexToRemove),
|
|
69
|
-
removedIndex: indexToRemove,
|
|
70
|
-
};
|
|
71
|
-
});
|
|
72
|
-
handleChanges(newResponses);
|
|
73
|
-
setNbRows((n) => n - 1);
|
|
74
|
-
},
|
|
75
|
-
[nbRows, min, value, handleChanges]
|
|
76
|
-
);
|
|
77
|
-
|
|
78
54
|
if (nbRows <= 0) {
|
|
79
55
|
return null;
|
|
80
56
|
}
|
|
@@ -88,25 +64,19 @@ export function Loop({
|
|
|
88
64
|
canControlRows={min !== max && Number.isFinite(max)}
|
|
89
65
|
>
|
|
90
66
|
{times(nbRows, (n) => (
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
/>
|
|
104
|
-
<Button onClick={() => removeRowWithIndex(n)} disabled={nbRows === 1}>
|
|
105
|
-
{D.DEFAULT_BUTTON_REMOVE_THAT_ROW}
|
|
106
|
-
</Button>
|
|
107
|
-
</>
|
|
67
|
+
<LunaticComponents
|
|
68
|
+
blocklist={blockedInLoopComponents}
|
|
69
|
+
key={n}
|
|
70
|
+
components={getComponents(n)}
|
|
71
|
+
componentProps={(c) => ({
|
|
72
|
+
...props,
|
|
73
|
+
...c,
|
|
74
|
+
iteration: n,
|
|
75
|
+
id: `${c.id}-${n}`,
|
|
76
|
+
errors,
|
|
77
|
+
})}
|
|
78
|
+
/>
|
|
108
79
|
))}
|
|
109
|
-
<br />
|
|
110
80
|
</CustomLoop>
|
|
111
81
|
);
|
|
112
82
|
}
|
|
@@ -2,7 +2,6 @@ import { Fragment, useCallback, useState } from 'react';
|
|
|
2
2
|
import type { LunaticComponentProps } from '../type';
|
|
3
3
|
import { Table, Tbody, Td, Tr, TableHeader } from '../shared/Table';
|
|
4
4
|
import { times } from '../../utils/array';
|
|
5
|
-
import D from '../../i18n';
|
|
6
5
|
import { LunaticComponents } from '../LunaticComponents';
|
|
7
6
|
import { blockedInLoopComponents } from '../Loop/constant';
|
|
8
7
|
import {
|
|
@@ -10,7 +9,6 @@ import {
|
|
|
10
9
|
getComponentErrors,
|
|
11
10
|
} from '../shared/ComponentErrors/ComponentErrors';
|
|
12
11
|
import { CustomLoop } from '../Loop/Loop';
|
|
13
|
-
import { Button } from '../shared/Button/Button';
|
|
14
12
|
|
|
15
13
|
const DEFAULT_MIN_ROWS = 1;
|
|
16
14
|
const DEFAULT_MAX_ROWS = 12;
|
|
@@ -46,8 +44,6 @@ export const RosterForLoop = (
|
|
|
46
44
|
}
|
|
47
45
|
}, [max, nbRows]);
|
|
48
46
|
|
|
49
|
-
const cantRemove = nbRows === min;
|
|
50
|
-
|
|
51
47
|
const removeRow = useCallback(() => {
|
|
52
48
|
if (nbRows <= min) {
|
|
53
49
|
return;
|
|
@@ -64,50 +60,22 @@ export const RosterForLoop = (
|
|
|
64
60
|
handleChanges(newResponses);
|
|
65
61
|
}, [nbRows, min, valueMap, handleChanges]);
|
|
66
62
|
|
|
67
|
-
const removeRowWithIndex = useCallback(
|
|
68
|
-
(indexToRemove: number) => {
|
|
69
|
-
if (nbRows <= min) {
|
|
70
|
-
return;
|
|
71
|
-
}
|
|
72
|
-
/**
|
|
73
|
-
* Case 0: trying to delete
|
|
74
|
-
*/
|
|
75
|
-
if (indexToRemove >= nbRows || indexToRemove < 0) {
|
|
76
|
-
return;
|
|
77
|
-
}
|
|
78
|
-
const newResponses = Object.entries(valueMap).map(([k, v]) => {
|
|
79
|
-
return {
|
|
80
|
-
name: k,
|
|
81
|
-
value: v?.filter((_, i) => i !== indexToRemove),
|
|
82
|
-
removedIndex: indexToRemove,
|
|
83
|
-
};
|
|
84
|
-
});
|
|
85
|
-
handleChanges(newResponses);
|
|
86
|
-
setNbRows((n) => n - 1);
|
|
87
|
-
},
|
|
88
|
-
[nbRows, min, valueMap, handleChanges]
|
|
89
|
-
);
|
|
90
|
-
|
|
91
63
|
if (nbRows === 0) {
|
|
92
64
|
return null;
|
|
93
65
|
}
|
|
94
66
|
|
|
95
67
|
let cols = 0;
|
|
96
68
|
|
|
97
|
-
const headerWithActions = header
|
|
98
|
-
? [...header, { label: D.ACTION_HEADER }]
|
|
99
|
-
: undefined;
|
|
100
|
-
|
|
101
69
|
return (
|
|
102
70
|
<CustomLoop
|
|
103
71
|
{...props}
|
|
104
72
|
errors={getComponentErrors(errors, props.id)}
|
|
105
73
|
addRow={nbRows === max ? undefined : addRow}
|
|
106
|
-
removeRow={
|
|
74
|
+
removeRow={nbRows === min ? undefined : removeRow}
|
|
107
75
|
canControlRows={!!(min && max && min !== max)}
|
|
108
76
|
>
|
|
109
77
|
<Table id={id}>
|
|
110
|
-
{
|
|
78
|
+
{header && <TableHeader header={header} />}
|
|
111
79
|
<Tbody>
|
|
112
80
|
{times(nbRows, (n) => {
|
|
113
81
|
const components = getComponents(n);
|
|
@@ -136,14 +104,6 @@ export const RosterForLoop = (
|
|
|
136
104
|
})}
|
|
137
105
|
wrapper={(props) => <Td {...props} />}
|
|
138
106
|
/>
|
|
139
|
-
<Td id={`delete-action-${n}`}>
|
|
140
|
-
<Button
|
|
141
|
-
onClick={() => removeRowWithIndex(n)}
|
|
142
|
-
disabled={cantRemove}
|
|
143
|
-
>
|
|
144
|
-
{D.DEFAULT_BUTTON_REMOVE_THAT_ROW}
|
|
145
|
-
</Button>
|
|
146
|
-
</Td>
|
|
147
107
|
</Tr>
|
|
148
108
|
{hasLineErrors && (
|
|
149
109
|
<Tr className="lunatic-errors">
|
|
@@ -45,15 +45,6 @@ exports[`RosterForLoop > renders the right number of columns 1`] = `
|
|
|
45
45
|
</div>
|
|
46
46
|
</div>
|
|
47
47
|
</td>
|
|
48
|
-
<td
|
|
49
|
-
class="lunatic-table-td"
|
|
50
|
-
>
|
|
51
|
-
<input
|
|
52
|
-
class="button-lunatic"
|
|
53
|
-
type="button"
|
|
54
|
-
value="Remove that row"
|
|
55
|
-
/>
|
|
56
|
-
</td>
|
|
57
48
|
</tr>
|
|
58
49
|
<tr
|
|
59
50
|
class="lunatic-table-tr"
|
|
@@ -84,15 +75,6 @@ exports[`RosterForLoop > renders the right number of columns 1`] = `
|
|
|
84
75
|
</div>
|
|
85
76
|
</div>
|
|
86
77
|
</td>
|
|
87
|
-
<td
|
|
88
|
-
class="lunatic-table-td"
|
|
89
|
-
>
|
|
90
|
-
<input
|
|
91
|
-
class="button-lunatic"
|
|
92
|
-
type="button"
|
|
93
|
-
value="Remove that row"
|
|
94
|
-
/>
|
|
95
|
-
</td>
|
|
96
78
|
</tr>
|
|
97
79
|
</tbody>
|
|
98
80
|
</table>
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import type {
|
|
2
|
+
ComponentDefinition,
|
|
3
|
+
ComponentRoundaboutDefinition,
|
|
4
|
+
LunaticSource,
|
|
5
|
+
} from '../type.source';
|
|
6
|
+
import type { LunaticData } from '../use-lunatic/type';
|
|
7
|
+
import { reducerInitializer } from '../use-lunatic/reducer/reducerInitializer';
|
|
8
|
+
import { type ReactNode, useMemo } from 'react';
|
|
9
|
+
import { times } from '../utils/array';
|
|
10
|
+
import { forceInt } from '../utils/number';
|
|
11
|
+
|
|
12
|
+
type ArticulationItem = {
|
|
13
|
+
label: string;
|
|
14
|
+
value: string;
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
type Articulation = {
|
|
18
|
+
source: string;
|
|
19
|
+
items: ArticulationItem[];
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
type Item = {
|
|
23
|
+
cells: {
|
|
24
|
+
label: string;
|
|
25
|
+
value: ReactNode;
|
|
26
|
+
page?: string;
|
|
27
|
+
}[];
|
|
28
|
+
progress: number; // -1: not completed, 0: started, 1: finished
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Hook to get articulation state
|
|
33
|
+
*
|
|
34
|
+
* ## Why this hook
|
|
35
|
+
*
|
|
36
|
+
* The goal of this hook is to provide insights about a roundabout using extra information inserted in the JSON source
|
|
37
|
+
* provided to Lunatic.
|
|
38
|
+
*
|
|
39
|
+
* For instance
|
|
40
|
+
*
|
|
41
|
+
* ```
|
|
42
|
+
* "articulation": {
|
|
43
|
+
* "source": "roundabout",
|
|
44
|
+
* "items": [
|
|
45
|
+
* {
|
|
46
|
+
* "label": "Prénom",
|
|
47
|
+
* "value": "PRENOMS"
|
|
48
|
+
* },
|
|
49
|
+
* {
|
|
50
|
+
* "label": "Sexe",
|
|
51
|
+
* "value": "if SEXE = \"H\" then \"Homme\" else \"Femme\""
|
|
52
|
+
* },
|
|
53
|
+
* {
|
|
54
|
+
* "label": "Age",
|
|
55
|
+
* "value": "cast(AGE, string) || \" ans\""
|
|
56
|
+
* }
|
|
57
|
+
* ]
|
|
58
|
+
* },
|
|
59
|
+
* ```
|
|
60
|
+
*
|
|
61
|
+
* - source is the ID of the roundabout component
|
|
62
|
+
* - items define the field to extract from the roundabout data
|
|
63
|
+
*/
|
|
64
|
+
export function useArticulation(
|
|
65
|
+
source: LunaticSource & { articulation: Articulation },
|
|
66
|
+
data: LunaticData
|
|
67
|
+
): { items: Item[] } {
|
|
68
|
+
const roundabout = useMemo(
|
|
69
|
+
() => findComponentById(source.components, source.articulation.source),
|
|
70
|
+
[source]
|
|
71
|
+
);
|
|
72
|
+
const { variables } = useMemo(
|
|
73
|
+
() => reducerInitializer({ source, data }),
|
|
74
|
+
[source, data]
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const iterations = useMemo(
|
|
78
|
+
() => forceInt(variables.run(roundabout?.iterations.value ?? '0')),
|
|
79
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80
|
+
[source, data]
|
|
81
|
+
);
|
|
82
|
+
|
|
83
|
+
const rows = useMemo(() => {
|
|
84
|
+
return times(iterations, (k) =>
|
|
85
|
+
source.articulation.items.map((item) => ({
|
|
86
|
+
label: item.label,
|
|
87
|
+
value: variables.run(item.value, { iteration: [k] }) as ReactNode,
|
|
88
|
+
}))
|
|
89
|
+
);
|
|
90
|
+
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
91
|
+
}, [source, data, iterations, roundabout?.progressVariable]);
|
|
92
|
+
|
|
93
|
+
if (!roundabout) {
|
|
94
|
+
return {
|
|
95
|
+
items: [],
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
return {
|
|
100
|
+
items: rows.map((row, k) => ({
|
|
101
|
+
cells: row,
|
|
102
|
+
progress: forceInt(variables.get(roundabout.progressVariable, [k]) ?? -1),
|
|
103
|
+
page: roundabout.page ? `${roundabout.page}.1#${k + 1}` : '1',
|
|
104
|
+
})),
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function findComponentById(
|
|
109
|
+
components: ComponentDefinition[],
|
|
110
|
+
id: string
|
|
111
|
+
): (ComponentRoundaboutDefinition & { page?: string }) | null {
|
|
112
|
+
for (const c of components) {
|
|
113
|
+
if ('id' in c && c.id === id && c.componentType === 'Roundabout') {
|
|
114
|
+
return c;
|
|
115
|
+
}
|
|
116
|
+
if ('components' in c) {
|
|
117
|
+
const child = findComponentById(c.components, id);
|
|
118
|
+
if (child) {
|
|
119
|
+
return child;
|
|
120
|
+
}
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
return null;
|
|
124
|
+
}
|
package/src/i18n/dictionary.ts
CHANGED
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
const dictionary = {
|
|
2
2
|
DEFAULT_BUTTON_ADD: { fr: 'Ajouter une ligne', en: 'Add row' },
|
|
3
3
|
DEFAULT_BUTTON_REMOVE: { fr: 'Supprimer une ligne', en: 'Remove row' },
|
|
4
|
-
DEFAULT_BUTTON_REMOVE_THAT_ROW: {
|
|
5
|
-
fr: 'Supprimer cette ligne',
|
|
6
|
-
en: 'Remove that row',
|
|
7
|
-
},
|
|
8
|
-
ACTION_HEADER: { fr: 'Action', en: 'Action' },
|
|
9
4
|
MODAL_IGNORE: { fr: 'Poursuivre', en: 'Ignore' },
|
|
10
5
|
MODAL_CORRECT: { fr: 'Corriger ma réponse', en: 'Correct' },
|
|
11
6
|
DK: { fr: 'Ne sais pas', en: "Don't know" },
|