@inseefr/lunatic 3.4.10-rc.1 → 3.4.11-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/README.md +6 -4
- package/components/Loop/Loop.js +27 -7
- package/components/Loop/Loop.js.map +1 -1
- package/components/LunaticComponents.d.ts +10 -1
- package/components/LunaticComponents.js +3 -1
- package/components/LunaticComponents.js.map +1 -1
- package/components/RosterForLoop/RosterForLoop.js +37 -8
- 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/components/shared/HOC/slottableComponent.d.ts +3 -3
- package/components/shared/HOC/slottableComponent.js +2 -2
- package/esm/components/Loop/Loop.js +27 -7
- package/esm/components/Loop/Loop.js.map +1 -1
- package/esm/components/LunaticComponents.d.ts +10 -1
- package/esm/components/LunaticComponents.js +3 -1
- package/esm/components/LunaticComponents.js.map +1 -1
- package/esm/components/RosterForLoop/RosterForLoop.js +34 -8
- 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/components/shared/HOC/slottableComponent.d.ts +3 -3
- package/esm/components/shared/HOC/slottableComponent.js +2 -2
- package/esm/i18n/dictionary.d.ts +8 -0
- package/esm/i18n/dictionary.js +5 -0
- package/esm/i18n/dictionary.js.map +1 -1
- package/esm/i18n/index.d.ts +1 -1
- package/esm/type.source.js +0 -1
- package/esm/type.source.js.map +1 -1
- package/esm/use-lunatic/commons/compile-controls.d.ts +1 -1
- package/esm/use-lunatic/commons/compile-controls.js +4 -3
- package/esm/use-lunatic/commons/compile-controls.js.map +1 -1
- package/esm/use-lunatic/commons/variables/behaviours/resizing-behaviour.js +23 -7
- package/esm/use-lunatic/commons/variables/behaviours/resizing-behaviour.js.map +1 -1
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.d.ts +19 -1
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.js +6 -6
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.js.map +1 -1
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.spec.js +66 -1
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.spec.js.map +1 -1
- package/esm/use-lunatic/hooks/use-loop-variables.d.ts +1 -1
- package/esm/use-lunatic/hooks/use-loop-variables.js +1 -1
- package/esm/use-lunatic/hooks/use-page-has-response.d.ts +1 -1
- package/esm/use-lunatic/hooks/use-page-has-response.js +6 -6
- package/esm/use-lunatic/hooks/useOverview.d.ts +1 -1
- package/esm/use-lunatic/hooks/useOverview.js +4 -4
- package/esm/use-lunatic/hooks/useWarnDepChange.d.ts +3 -2
- package/esm/use-lunatic/hooks/useWarnDepChange.js +3 -2
- package/esm/use-lunatic/hooks/useWarnDepChange.js.map +1 -1
- package/esm/use-lunatic/lunatic-context.d.ts +5 -2
- package/esm/use-lunatic/lunatic-context.js +5 -2
- package/esm/use-lunatic/lunatic-context.js.map +1 -1
- package/esm/use-lunatic/props/getComponentTypeProps.d.ts +4 -4
- package/esm/use-lunatic/reducer/commons/index.d.ts +0 -1
- package/esm/use-lunatic/reducer/commons/index.js +0 -1
- package/esm/use-lunatic/reducer/commons/index.js.map +1 -1
- package/esm/use-lunatic/type.d.ts +153 -2
- package/esm/use-lunatic/use-lunatic.d.ts +13 -36
- package/esm/use-lunatic/use-lunatic.js +13 -2
- package/esm/use-lunatic/use-lunatic.js.map +1 -1
- package/esm/utils/array.d.ts +4 -0
- package/esm/utils/array.js +15 -2
- package/esm/utils/array.js.map +1 -1
- package/esm/utils/array.spec.js +12 -1
- package/esm/utils/array.spec.js.map +1 -1
- package/i18n/dictionary.d.ts +8 -0
- package/i18n/dictionary.js +5 -0
- package/i18n/dictionary.js.map +1 -1
- package/i18n/index.d.ts +1 -1
- package/package.json +1 -8
- package/src/components/Loop/Loop.tsx +42 -12
- package/src/components/LunaticComponents.tsx +10 -8
- package/src/components/RosterForLoop/RosterForLoop.tsx +42 -2
- package/src/components/RosterForLoop/__snapshots__/RosterForLoop.spec.tsx.snap +18 -0
- package/src/components/shared/HOC/slottableComponent.tsx +3 -3
- package/src/i18n/dictionary.ts +5 -0
- package/src/stories/pairwise/data.json +1 -1
- package/src/stories/pairwise/source.json +3 -1
- package/src/type.source.ts +0 -1
- package/src/use-lunatic/__snapshots__/use-lunatic.test.ts.snap +0 -323
- package/src/use-lunatic/commons/compile-controls.ts +4 -3
- package/src/use-lunatic/commons/variables/behaviours/resizing-behaviour.ts +35 -10
- package/src/use-lunatic/commons/variables/lunatic-variables-store.spec.ts +68 -1
- package/src/use-lunatic/commons/variables/lunatic-variables-store.ts +21 -19
- package/src/use-lunatic/hooks/use-loop-variables.ts +1 -1
- package/src/use-lunatic/hooks/use-page-has-response.ts +6 -6
- package/src/use-lunatic/hooks/useOverview.ts +4 -4
- package/src/use-lunatic/hooks/useWarnDepChange.ts +3 -2
- package/src/use-lunatic/lunatic-context.tsx +5 -2
- package/src/use-lunatic/reducer/commons/index.ts +0 -1
- package/src/use-lunatic/type.ts +154 -17
- package/src/use-lunatic/use-lunatic.ts +11 -2
- package/src/utils/array.spec.ts +18 -1
- package/src/utils/array.ts +21 -3
- package/tsconfig.build.tsbuildinfo +1 -1
- package/type.source.js +0 -1
- package/type.source.js.map +1 -1
- package/use-lunatic/commons/compile-controls.d.ts +1 -1
- package/use-lunatic/commons/compile-controls.js +4 -3
- package/use-lunatic/commons/compile-controls.js.map +1 -1
- package/use-lunatic/commons/variables/behaviours/resizing-behaviour.js +22 -6
- package/use-lunatic/commons/variables/behaviours/resizing-behaviour.js.map +1 -1
- package/use-lunatic/commons/variables/lunatic-variables-store.d.ts +19 -1
- package/use-lunatic/commons/variables/lunatic-variables-store.js +13 -13
- package/use-lunatic/commons/variables/lunatic-variables-store.js.map +1 -1
- package/use-lunatic/commons/variables/lunatic-variables-store.spec.js +66 -1
- package/use-lunatic/commons/variables/lunatic-variables-store.spec.js.map +1 -1
- package/use-lunatic/hooks/use-loop-variables.d.ts +1 -1
- package/use-lunatic/hooks/use-loop-variables.js +1 -1
- package/use-lunatic/hooks/use-page-has-response.d.ts +1 -1
- package/use-lunatic/hooks/use-page-has-response.js +6 -6
- package/use-lunatic/hooks/useOverview.d.ts +1 -1
- package/use-lunatic/hooks/useOverview.js +4 -4
- package/use-lunatic/hooks/useWarnDepChange.d.ts +3 -2
- package/use-lunatic/hooks/useWarnDepChange.js +3 -2
- package/use-lunatic/hooks/useWarnDepChange.js.map +1 -1
- package/use-lunatic/lunatic-context.d.ts +5 -2
- package/use-lunatic/lunatic-context.js +5 -2
- package/use-lunatic/lunatic-context.js.map +1 -1
- package/use-lunatic/props/getComponentTypeProps.d.ts +4 -4
- package/use-lunatic/reducer/commons/index.d.ts +0 -1
- package/use-lunatic/reducer/commons/index.js +0 -6
- package/use-lunatic/reducer/commons/index.js.map +1 -1
- package/use-lunatic/type.d.ts +153 -2
- package/use-lunatic/use-lunatic.d.ts +13 -36
- package/use-lunatic/use-lunatic.js +13 -2
- package/use-lunatic/use-lunatic.js.map +1 -1
- package/utils/array.d.ts +4 -0
- package/utils/array.js +16 -2
- package/utils/array.js.map +1 -1
- package/utils/array.spec.js +11 -0
- package/utils/array.spec.js.map +1 -1
- package/esm/use-lunatic/reducer/commons/resize-array-variable.d.ts +0 -5
- package/esm/use-lunatic/reducer/commons/resize-array-variable.js +0 -21
- package/esm/use-lunatic/reducer/commons/resize-array-variable.js.map +0 -1
- package/src/use-lunatic/reducer/commons/resize-array-variable.ts +0 -28
- package/use-lunatic/reducer/commons/resize-array-variable.d.ts +0 -5
- package/use-lunatic/reducer/commons/resize-array-variable.js +0 -23
- package/use-lunatic/reducer/commons/resize-array-variable.js.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"array.spec.js","sourceRoot":"","sources":["../../src/utils/array.spec.ts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C,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;YACzE,MAAM,CAAC,wBAAwB,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC;QACzE,CAAC,CAAC,CAAC;IACJ,CAAC,CAAC,CAAC;AACJ,CAAC,CAAC,CAAC"}
|
package/i18n/dictionary.d.ts
CHANGED
|
@@ -7,6 +7,14 @@ 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
|
+
};
|
|
10
18
|
readonly MODAL_IGNORE: {
|
|
11
19
|
readonly fr: "Poursuivre";
|
|
12
20
|
readonly en: "Ignore";
|
package/i18n/dictionary.js
CHANGED
|
@@ -3,6 +3,11 @@ 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' },
|
|
6
11
|
MODAL_IGNORE: { fr: 'Poursuivre', en: 'Ignore' },
|
|
7
12
|
MODAL_CORRECT: { fr: 'Corriger ma réponse', en: 'Correct' },
|
|
8
13
|
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,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"}
|
|
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,8BAA8B,EAAE;QAC/B,EAAE,EAAE,uBAAuB;QAC3B,EAAE,EAAE,iBAAiB;KACrB;IACD,aAAa,EAAE,EAAE,EAAE,EAAE,QAAQ,EAAE,EAAE,EAAE,QAAQ,EAAE;IAC7C,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" | "MODAL_IGNORE" | "MODAL_CORRECT" | "PLACEHOLDER" | "SUGGESTER_LOADING" | "SUGGESTER_NO_RESULT" | "SUGGESTER_ERROR" | "SUGGESTER_ARBITRARY", string>;
|
|
6
|
+
declare const _default: Record<"DK" | "RF" | "DEFAULT_BUTTON_ADD" | "DEFAULT_BUTTON_REMOVE" | "DEFAULT_BUTTON_REMOVE_THAT_ROW" | "ACTION_HEADER" | "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.4.
|
|
3
|
+
"version": "3.4.11-rc.0",
|
|
4
4
|
"description": "Library of questionnaire components",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -428,7 +428,6 @@
|
|
|
428
428
|
"src/use-lunatic/props/propValue.ts",
|
|
429
429
|
"src/use-lunatic/reducer/commons/auto-explore-loop.ts",
|
|
430
430
|
"src/use-lunatic/reducer/commons/index.ts",
|
|
431
|
-
"src/use-lunatic/reducer/commons/resize-array-variable.ts",
|
|
432
431
|
"src/use-lunatic/reducer/commons/validate-condition-filter.ts",
|
|
433
432
|
"src/use-lunatic/reducer/controls/check-base-control.ts",
|
|
434
433
|
"src/use-lunatic/reducer/controls/check-roundabout-control.ts",
|
|
@@ -1528,9 +1527,6 @@
|
|
|
1528
1527
|
"esm/use-lunatic/reducer/commons/index.d.ts",
|
|
1529
1528
|
"esm/use-lunatic/reducer/commons/index.js",
|
|
1530
1529
|
"esm/use-lunatic/reducer/commons/index.js.map",
|
|
1531
|
-
"esm/use-lunatic/reducer/commons/resize-array-variable.d.ts",
|
|
1532
|
-
"esm/use-lunatic/reducer/commons/resize-array-variable.js",
|
|
1533
|
-
"esm/use-lunatic/reducer/commons/resize-array-variable.js.map",
|
|
1534
1530
|
"esm/use-lunatic/reducer/commons/validate-condition-filter.d.ts",
|
|
1535
1531
|
"esm/use-lunatic/reducer/commons/validate-condition-filter.js",
|
|
1536
1532
|
"esm/use-lunatic/reducer/commons/validate-condition-filter.js.map",
|
|
@@ -1852,9 +1848,6 @@
|
|
|
1852
1848
|
"use-lunatic/reducer/commons/index.d.ts",
|
|
1853
1849
|
"use-lunatic/reducer/commons/index.js",
|
|
1854
1850
|
"use-lunatic/reducer/commons/index.js.map",
|
|
1855
|
-
"use-lunatic/reducer/commons/resize-array-variable.d.ts",
|
|
1856
|
-
"use-lunatic/reducer/commons/resize-array-variable.js",
|
|
1857
|
-
"use-lunatic/reducer/commons/resize-array-variable.js.map",
|
|
1858
1851
|
"use-lunatic/reducer/commons/validate-condition-filter.d.ts",
|
|
1859
1852
|
"use-lunatic/reducer/commons/validate-condition-filter.js",
|
|
1860
1853
|
"use-lunatic/reducer/commons/validate-condition-filter.js.map",
|
|
@@ -51,6 +51,30 @@ 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
|
+
|
|
54
78
|
if (nbRows <= 0) {
|
|
55
79
|
return null;
|
|
56
80
|
}
|
|
@@ -64,19 +88,25 @@ export function Loop({
|
|
|
64
88
|
canControlRows={min !== max && Number.isFinite(max)}
|
|
65
89
|
>
|
|
66
90
|
{times(nbRows, (n) => (
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
91
|
+
<>
|
|
92
|
+
<LunaticComponents
|
|
93
|
+
blocklist={blockedInLoopComponents}
|
|
94
|
+
key={n}
|
|
95
|
+
components={getComponents(n)}
|
|
96
|
+
componentProps={(c) => ({
|
|
97
|
+
...props,
|
|
98
|
+
...c,
|
|
99
|
+
iteration: n,
|
|
100
|
+
id: `${c.id}-${n}`,
|
|
101
|
+
errors,
|
|
102
|
+
})}
|
|
103
|
+
/>
|
|
104
|
+
<Button onClick={() => removeRowWithIndex(n)} disabled={nbRows === 1}>
|
|
105
|
+
{D.DEFAULT_BUTTON_REMOVE_THAT_ROW}
|
|
106
|
+
</Button>
|
|
107
|
+
</>
|
|
79
108
|
))}
|
|
109
|
+
<br />
|
|
80
110
|
</CustomLoop>
|
|
81
111
|
);
|
|
82
112
|
}
|
|
@@ -19,21 +19,21 @@ import {
|
|
|
19
19
|
import type { LunaticComponentProps } from './type';
|
|
20
20
|
|
|
21
21
|
type Props<V = unknown> = {
|
|
22
|
-
|
|
22
|
+
/** List of components to display (coming from getComponents). */
|
|
23
23
|
components: LunaticComponentProps[];
|
|
24
|
-
|
|
24
|
+
/** Should we memoized children. */
|
|
25
25
|
memo?: boolean;
|
|
26
|
-
|
|
26
|
+
/** Key that trigger autofocus when it changes (pageTag). */
|
|
27
27
|
autoFocusKey?: string;
|
|
28
|
-
|
|
28
|
+
/** Returns the list of extra props to add to components. */
|
|
29
29
|
componentProps?: (component: LunaticComponentProps) => V;
|
|
30
|
-
|
|
30
|
+
/** Forbidden components. */
|
|
31
31
|
blocklist?: string[];
|
|
32
|
-
|
|
32
|
+
/** Add additional wrapper around each component. */
|
|
33
33
|
wrapper?: (
|
|
34
34
|
props: PropsWithChildren<LunaticComponentProps & V & { index: number }>
|
|
35
35
|
) => ReactNode;
|
|
36
|
-
|
|
36
|
+
/** Customized deep components. */
|
|
37
37
|
slots?: Partial<LunaticSlotComponents>;
|
|
38
38
|
};
|
|
39
39
|
|
|
@@ -45,7 +45,9 @@ const LunaticComponentWrapper = slottableComponent(
|
|
|
45
45
|
);
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
* Entry point for orchestrators, this component display the list of fields
|
|
48
|
+
* Entry point for orchestrators, this component display the list of fields.
|
|
49
|
+
*
|
|
50
|
+
* Components offered by Lunatic can be seen at {@link https://github.com/InseeFr/Lunatic/tree/3.0/src/components}
|
|
49
51
|
*/
|
|
50
52
|
export function LunaticComponents<V = unknown>({
|
|
51
53
|
components,
|
|
@@ -2,6 +2,7 @@ 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';
|
|
5
6
|
import { LunaticComponents } from '../LunaticComponents';
|
|
6
7
|
import { blockedInLoopComponents } from '../Loop/constant';
|
|
7
8
|
import {
|
|
@@ -9,6 +10,7 @@ import {
|
|
|
9
10
|
getComponentErrors,
|
|
10
11
|
} from '../shared/ComponentErrors/ComponentErrors';
|
|
11
12
|
import { CustomLoop } from '../Loop/Loop';
|
|
13
|
+
import { Button } from '../shared/Button/Button';
|
|
12
14
|
|
|
13
15
|
const DEFAULT_MIN_ROWS = 1;
|
|
14
16
|
const DEFAULT_MAX_ROWS = 12;
|
|
@@ -44,6 +46,8 @@ export const RosterForLoop = (
|
|
|
44
46
|
}
|
|
45
47
|
}, [max, nbRows]);
|
|
46
48
|
|
|
49
|
+
const cantRemove = nbRows === min;
|
|
50
|
+
|
|
47
51
|
const removeRow = useCallback(() => {
|
|
48
52
|
if (nbRows <= min) {
|
|
49
53
|
return;
|
|
@@ -60,22 +64,50 @@ export const RosterForLoop = (
|
|
|
60
64
|
handleChanges(newResponses);
|
|
61
65
|
}, [nbRows, min, valueMap, handleChanges]);
|
|
62
66
|
|
|
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
|
+
|
|
63
91
|
if (nbRows === 0) {
|
|
64
92
|
return null;
|
|
65
93
|
}
|
|
66
94
|
|
|
67
95
|
let cols = 0;
|
|
68
96
|
|
|
97
|
+
const headerWithActions = header
|
|
98
|
+
? [...header, { label: D.ACTION_HEADER }]
|
|
99
|
+
: undefined;
|
|
100
|
+
|
|
69
101
|
return (
|
|
70
102
|
<CustomLoop
|
|
71
103
|
{...props}
|
|
72
104
|
errors={getComponentErrors(errors, props.id)}
|
|
73
105
|
addRow={nbRows === max ? undefined : addRow}
|
|
74
|
-
removeRow={
|
|
106
|
+
removeRow={cantRemove ? undefined : removeRow}
|
|
75
107
|
canControlRows={!!(min && max && min !== max)}
|
|
76
108
|
>
|
|
77
109
|
<Table id={id}>
|
|
78
|
-
{
|
|
110
|
+
{headerWithActions && <TableHeader header={headerWithActions} />}
|
|
79
111
|
<Tbody>
|
|
80
112
|
{times(nbRows, (n) => {
|
|
81
113
|
const components = getComponents(n);
|
|
@@ -104,6 +136,14 @@ export const RosterForLoop = (
|
|
|
104
136
|
})}
|
|
105
137
|
wrapper={(props) => <Td {...props} />}
|
|
106
138
|
/>
|
|
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>
|
|
107
147
|
</Tr>
|
|
108
148
|
{hasLineErrors && (
|
|
109
149
|
<Tr className="lunatic-errors">
|
|
@@ -45,6 +45,15 @@ 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>
|
|
48
57
|
</tr>
|
|
49
58
|
<tr
|
|
50
59
|
class="lunatic-table-tr"
|
|
@@ -75,6 +84,15 @@ exports[`RosterForLoop > renders the right number of columns 1`] = `
|
|
|
75
84
|
</div>
|
|
76
85
|
</div>
|
|
77
86
|
</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>
|
|
78
96
|
</tr>
|
|
79
97
|
</tbody>
|
|
80
98
|
</table>
|
|
@@ -45,7 +45,7 @@ import type { MarkdownLink } from '../MDLabel/MarkdownLink';
|
|
|
45
45
|
import type { Accordion } from '../../Accordion/Accordion';
|
|
46
46
|
|
|
47
47
|
/**
|
|
48
|
-
*
|
|
48
|
+
* Contain the type of every customizable components.
|
|
49
49
|
*/
|
|
50
50
|
export type LunaticSlotComponents = {
|
|
51
51
|
// Components
|
|
@@ -130,9 +130,9 @@ export const SlotsProvider = ({
|
|
|
130
130
|
};
|
|
131
131
|
|
|
132
132
|
/**
|
|
133
|
-
* Create a replaceable version of a component
|
|
133
|
+
* Create a replaceable version of a component.
|
|
134
134
|
*
|
|
135
|
-
* The component can be replaced
|
|
135
|
+
* The component can be replaced through the `slots` props on `LunaticComponents`.
|
|
136
136
|
*/
|
|
137
137
|
export function slottableComponent<T>(
|
|
138
138
|
name: keyof LunaticSlotComponents,
|
package/src/i18n/dictionary.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
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' },
|
|
4
9
|
MODAL_IGNORE: { fr: 'Poursuivre', en: 'Ignore' },
|
|
5
10
|
MODAL_CORRECT: { fr: 'Corriger ma réponse', en: 'Correct' },
|
|
6
11
|
DK: { fr: 'Ne sais pas', en: "Don't know" },
|
package/src/type.source.ts
CHANGED