@inseefr/lunatic 3.11.2 → 3.12.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/Accordion/Accordion.d.ts +1 -1
- package/components/Datepicker/DatepickerFields.js +4 -2
- package/components/Datepicker/DatepickerFields.js.map +1 -1
- package/components/Duration/getDurationFromValue.js +3 -3
- package/components/Duration/getDurationFromValue.js.map +1 -1
- package/components/FilterDescription/FilterDescription.d.ts +1 -1
- package/components/LunaticComponents.d.ts +1 -1
- package/components/LunaticComponents.js +9 -7
- package/components/LunaticComponents.js.map +1 -1
- package/components/PairwiseLinks/PairwiseLinks.d.ts +1 -1
- package/components/PairwiseLinks/PairwiseLinks.js +15 -30
- package/components/PairwiseLinks/PairwiseLinks.js.map +1 -1
- package/components/PairwiseLinks/PairwiseMirror.d.ts +2 -0
- package/components/PairwiseLinks/PairwiseMirror.js +14 -0
- package/components/PairwiseLinks/PairwiseMirror.js.map +1 -0
- package/components/PairwiseLinks/combinations.d.ts +18 -0
- package/components/PairwiseLinks/combinations.js +29 -0
- package/components/PairwiseLinks/combinations.js.map +1 -0
- package/components/Radio/Radio.d.ts +1 -1
- package/components/Sequence/Sequence.d.ts +1 -1
- package/components/Subsequence/Subsequence.d.ts +1 -1
- package/components/Switch/Switch.d.ts +1 -1
- package/components/library.d.ts +6 -6
- package/components/type.d.ts +25 -28
- package/esm/components/Accordion/Accordion.d.ts +1 -1
- package/esm/components/Datepicker/DatepickerFields.js +4 -2
- package/esm/components/Datepicker/DatepickerFields.js.map +1 -1
- package/esm/components/Duration/getDurationFromValue.js +3 -3
- package/esm/components/Duration/getDurationFromValue.js.map +1 -1
- package/esm/components/FilterDescription/FilterDescription.d.ts +1 -1
- package/esm/components/LunaticComponents.d.ts +1 -1
- package/esm/components/LunaticComponents.js +9 -7
- package/esm/components/LunaticComponents.js.map +1 -1
- package/esm/components/PairwiseLinks/PairwiseLinks.d.ts +1 -1
- package/esm/components/PairwiseLinks/PairwiseLinks.js +16 -31
- package/esm/components/PairwiseLinks/PairwiseLinks.js.map +1 -1
- package/esm/components/PairwiseLinks/PairwiseMirror.d.ts +2 -0
- package/esm/components/PairwiseLinks/PairwiseMirror.js +10 -0
- package/esm/components/PairwiseLinks/PairwiseMirror.js.map +1 -0
- package/esm/components/PairwiseLinks/combinations.d.ts +18 -0
- package/esm/components/PairwiseLinks/combinations.js +24 -0
- package/esm/components/PairwiseLinks/combinations.js.map +1 -0
- package/esm/components/Radio/Radio.d.ts +1 -1
- package/esm/components/Sequence/Sequence.d.ts +1 -1
- package/esm/components/Subsequence/Subsequence.d.ts +1 -1
- package/esm/components/Switch/Switch.d.ts +1 -1
- package/esm/components/library.d.ts +6 -6
- package/esm/components/type.d.ts +25 -28
- package/esm/index.d.ts +1 -1
- package/esm/index.js.map +1 -1
- package/esm/type.source.d.ts +43 -13
- package/esm/type.source.js +0 -1
- package/esm/type.source.js.map +1 -1
- package/esm/use-lunatic/commons/compile-controls.js +1 -1
- package/esm/use-lunatic/commons/compile-controls.js.map +1 -1
- package/esm/use-lunatic/commons/component.d.ts +3 -2
- package/esm/use-lunatic/commons/component.js +5 -0
- package/esm/use-lunatic/commons/component.js.map +1 -1
- package/esm/use-lunatic/commons/fill-components/fill-component-expressions.d.ts +1 -1
- package/esm/use-lunatic/commons/fill-components/fill-component-expressions.js +1 -42
- package/esm/use-lunatic/commons/fill-components/fill-component-expressions.js.map +1 -1
- package/esm/use-lunatic/commons/fill-components/fill-components.js +10 -2
- package/esm/use-lunatic/commons/fill-components/fill-components.js.map +1 -1
- package/esm/use-lunatic/commons/index.d.ts +4 -4
- package/esm/use-lunatic/commons/index.js +4 -4
- package/esm/use-lunatic/commons/index.js.map +1 -1
- package/esm/use-lunatic/commons/{check-loops.d.ts → pagination/check-loops.d.ts} +7 -7
- package/esm/use-lunatic/commons/{check-loops.js → pagination/check-loops.js} +3 -5
- package/esm/use-lunatic/commons/pagination/check-loops.js.map +1 -0
- package/{use-lunatic/commons → esm/use-lunatic/commons/pagination}/check-pager.d.ts +1 -1
- package/esm/use-lunatic/commons/pagination/check-pager.js.map +1 -0
- package/{use-lunatic/commons → esm/use-lunatic/commons/pagination}/create-map-pages.d.ts +1 -1
- package/esm/use-lunatic/commons/pagination/create-map-pages.js.map +1 -0
- package/esm/use-lunatic/commons/{is-First-last-page.d.ts → pagination/is-First-last-page.d.ts} +1 -1
- package/esm/use-lunatic/commons/pagination/is-First-last-page.js.map +1 -0
- package/{use-lunatic/commons → esm/use-lunatic/commons/pagination}/is-paginated-loop.d.ts +1 -1
- package/esm/use-lunatic/commons/pagination/is-paginated-loop.js.map +1 -0
- package/esm/use-lunatic/commons/{is-roundabout.d.ts → pagination/is-roundabout.d.ts} +1 -1
- package/esm/use-lunatic/commons/pagination/is-roundabout.js.map +1 -0
- package/esm/use-lunatic/commons/{page-navigation.d.ts → pagination/page-navigation.d.ts} +2 -2
- package/esm/use-lunatic/commons/{page-navigation.js → pagination/page-navigation.js} +6 -6
- package/esm/use-lunatic/commons/pagination/page-navigation.js.map +1 -0
- package/esm/use-lunatic/commons/pagination/page-navigation.spec.js.map +1 -0
- package/esm/use-lunatic/commons/{page-tag.d.ts → pagination/page-tag.d.ts} +8 -1
- package/esm/use-lunatic/commons/{page-tag.js → pagination/page-tag.js} +17 -6
- package/esm/use-lunatic/commons/pagination/page-tag.js.map +1 -0
- package/esm/use-lunatic/commons/{page-tag.spec.js → pagination/page-tag.spec.js} +9 -1
- package/esm/use-lunatic/commons/pagination/page-tag.spec.js.map +1 -0
- package/{use-lunatic/commons → esm/use-lunatic/commons/pagination}/page.d.ts +1 -1
- package/esm/use-lunatic/commons/{page.js → pagination/page.js} +2 -2
- package/esm/use-lunatic/commons/pagination/page.js.map +1 -0
- package/esm/use-lunatic/hooks/use-page-has-response.js +37 -21
- package/esm/use-lunatic/hooks/use-page-has-response.js.map +1 -1
- package/esm/use-lunatic/hooks/useOverview.js +2 -2
- package/esm/use-lunatic/hooks/useOverview.js.map +1 -1
- package/esm/use-lunatic/props/getComponentTypeProps.d.ts +28 -26
- package/esm/use-lunatic/props/getComponentTypeProps.js +3 -1
- package/esm/use-lunatic/props/getComponentTypeProps.js.map +1 -1
- package/esm/use-lunatic/props/propOptions.d.ts +9 -1
- package/esm/use-lunatic/props/propOptions.js +56 -1
- package/esm/use-lunatic/props/propOptions.js.map +1 -1
- package/esm/use-lunatic/props/propOptions.spec.js +220 -56
- package/esm/use-lunatic/props/propOptions.spec.js.map +1 -1
- package/esm/use-lunatic/reducer/commons/auto-explore-loop.js +3 -2
- package/esm/use-lunatic/reducer/commons/auto-explore-loop.js.map +1 -1
- package/esm/use-lunatic/reducer/overview/overviewOnInit.d.ts +1 -2
- package/esm/use-lunatic/reducer/overview/overviewOnInit.js +1 -1
- package/esm/use-lunatic/reducer/overview/overviewOnInit.js.map +1 -1
- package/esm/use-lunatic/reducer/reduce-go-next-page.js +4 -3
- package/esm/use-lunatic/reducer/reduce-go-next-page.js.map +1 -1
- package/esm/use-lunatic/reducer/reduce-go-previous-page.js +2 -2
- package/esm/use-lunatic/reducer/reduce-go-previous-page.js.map +1 -1
- package/esm/use-lunatic/reducer/reduce-go-to-page.js +2 -2
- package/esm/use-lunatic/reducer/reduce-go-to-page.js.map +1 -1
- package/esm/use-lunatic/reducer/reducerInitializer.js +2 -2
- package/esm/use-lunatic/reducer/reducerInitializer.js.map +1 -1
- package/esm/use-lunatic/type.d.ts +1 -1
- package/esm/utils/cast.js +5 -2
- package/esm/utils/cast.js.map +1 -1
- package/esm/utils/getArticulationState.js +2 -1
- package/esm/utils/getArticulationState.js.map +1 -1
- package/esm/utils/number.js +4 -4
- package/esm/utils/number.js.map +1 -1
- package/index.d.ts +1 -1
- package/index.js.map +1 -1
- package/package.json +98 -79
- package/src/components/Datepicker/DatepickerFields.tsx +4 -2
- package/src/components/Duration/getDurationFromValue.ts +3 -3
- package/src/components/LunaticComponents.tsx +32 -25
- package/src/components/PairwiseLinks/PairwiseLinks.tsx +18 -57
- package/src/components/PairwiseLinks/PairwiseMirror.tsx +19 -0
- package/src/components/PairwiseLinks/combinations.test.ts +103 -0
- package/src/components/PairwiseLinks/combinations.ts +34 -0
- package/src/components/type.ts +204 -231
- package/src/index.ts +1 -4
- package/src/stories/checkbox/checkbox.stories.tsx +13 -0
- package/src/stories/checkbox/sourceOneDynamicOptions.json +496 -0
- package/src/stories/dropdown/dropdown.stories.tsx +12 -0
- package/src/stories/dropdown/sourceDynamicOptions.json +496 -0
- package/src/stories/pairwise/pairwise.stories.tsx +17 -1
- package/src/stories/pairwise/sourcePairwiseLoop.json +356 -0
- package/src/stories/radio/radio.stories.tsx +13 -0
- package/src/stories/radio/sourceDynamicOptions.json +496 -0
- package/src/type.source.ts +45 -14
- package/src/use-lunatic/commons/compile-controls.ts +1 -1
- package/src/use-lunatic/commons/component.ts +7 -2
- package/src/use-lunatic/commons/fill-components/fill-component-expressions.ts +3 -46
- package/src/use-lunatic/commons/fill-components/fill-components.ts +9 -10
- package/src/use-lunatic/commons/index.ts +8 -4
- package/src/use-lunatic/commons/{check-loops.ts → pagination/check-loops.ts} +4 -10
- package/src/use-lunatic/commons/{check-pager.ts → pagination/check-pager.ts} +1 -1
- package/src/use-lunatic/commons/{create-map-pages.ts → pagination/create-map-pages.ts} +2 -2
- package/src/use-lunatic/commons/{is-First-last-page.ts → pagination/is-First-last-page.ts} +1 -1
- package/src/use-lunatic/commons/{is-paginated-loop.ts → pagination/is-paginated-loop.ts} +1 -1
- package/src/use-lunatic/commons/{is-roundabout.ts → pagination/is-roundabout.ts} +1 -1
- package/src/use-lunatic/commons/{page-navigation.spec.ts → pagination/page-navigation.spec.ts} +1 -1
- package/src/use-lunatic/commons/{page-navigation.ts → pagination/page-navigation.ts} +8 -8
- package/src/use-lunatic/commons/{page-tag.spec.ts → pagination/page-tag.spec.ts} +15 -2
- package/src/use-lunatic/commons/{page-tag.ts → pagination/page-tag.ts} +18 -7
- package/src/use-lunatic/commons/{page.ts → pagination/page.ts} +6 -3
- package/src/use-lunatic/hooks/use-page-has-response.ts +59 -28
- package/src/use-lunatic/hooks/useOverview.ts +6 -3
- package/src/use-lunatic/props/getComponentTypeProps.ts +2 -1
- package/src/use-lunatic/props/propOptions.spec.ts +217 -147
- package/src/use-lunatic/props/propOptions.ts +99 -10
- package/src/use-lunatic/reducer/commons/auto-explore-loop.ts +3 -2
- package/src/use-lunatic/reducer/overview/overviewOnInit.ts +2 -2
- package/src/use-lunatic/reducer/reduce-go-next-page.ts +4 -3
- package/src/use-lunatic/reducer/reduce-go-previous-page.ts +2 -2
- package/src/use-lunatic/reducer/reduce-go-to-page.ts +2 -2
- package/src/use-lunatic/reducer/reducerInitializer.tsx +2 -2
- package/src/use-lunatic/type.ts +1 -1
- package/src/utils/cast.ts +5 -2
- package/src/utils/getArticulationState.ts +2 -1
- package/src/utils/number.ts +4 -4
- package/tsconfig.build.tsbuildinfo +1 -1
- package/type.source.d.ts +43 -13
- package/type.source.js +0 -1
- package/type.source.js.map +1 -1
- package/use-lunatic/commons/compile-controls.js +1 -1
- package/use-lunatic/commons/compile-controls.js.map +1 -1
- package/use-lunatic/commons/component.d.ts +3 -2
- package/use-lunatic/commons/component.js +5 -0
- package/use-lunatic/commons/component.js.map +1 -1
- package/use-lunatic/commons/fill-components/fill-component-expressions.d.ts +1 -1
- package/use-lunatic/commons/fill-components/fill-component-expressions.js +12 -53
- package/use-lunatic/commons/fill-components/fill-component-expressions.js.map +1 -1
- package/use-lunatic/commons/fill-components/fill-components.js +9 -1
- package/use-lunatic/commons/fill-components/fill-components.js.map +1 -1
- package/use-lunatic/commons/index.d.ts +4 -4
- package/use-lunatic/commons/index.js +4 -4
- package/use-lunatic/commons/index.js.map +1 -1
- package/use-lunatic/commons/{check-loops.d.ts → pagination/check-loops.d.ts} +7 -7
- package/use-lunatic/commons/{check-loops.js → pagination/check-loops.js} +3 -5
- package/use-lunatic/commons/pagination/check-loops.js.map +1 -0
- package/{esm/use-lunatic/commons → use-lunatic/commons/pagination}/check-pager.d.ts +1 -1
- package/use-lunatic/commons/pagination/check-pager.js.map +1 -0
- package/{esm/use-lunatic/commons → use-lunatic/commons/pagination}/create-map-pages.d.ts +1 -1
- package/use-lunatic/commons/pagination/create-map-pages.js.map +1 -0
- package/use-lunatic/commons/{is-First-last-page.d.ts → pagination/is-First-last-page.d.ts} +1 -1
- package/use-lunatic/commons/pagination/is-First-last-page.js.map +1 -0
- package/{esm/use-lunatic/commons → use-lunatic/commons/pagination}/is-paginated-loop.d.ts +1 -1
- package/use-lunatic/commons/pagination/is-paginated-loop.js.map +1 -0
- package/use-lunatic/commons/{is-roundabout.d.ts → pagination/is-roundabout.d.ts} +1 -1
- package/use-lunatic/commons/pagination/is-roundabout.js.map +1 -0
- package/use-lunatic/commons/{page-navigation.d.ts → pagination/page-navigation.d.ts} +2 -2
- package/use-lunatic/commons/{page-navigation.js → pagination/page-navigation.js} +6 -6
- package/use-lunatic/commons/pagination/page-navigation.js.map +1 -0
- package/use-lunatic/commons/pagination/page-navigation.spec.js.map +1 -0
- package/use-lunatic/commons/{page-tag.d.ts → pagination/page-tag.d.ts} +8 -1
- package/use-lunatic/commons/{page-tag.js → pagination/page-tag.js} +18 -6
- package/use-lunatic/commons/pagination/page-tag.js.map +1 -0
- package/use-lunatic/commons/{page-tag.spec.js → pagination/page-tag.spec.js} +8 -0
- package/use-lunatic/commons/pagination/page-tag.spec.js.map +1 -0
- package/{esm/use-lunatic/commons → use-lunatic/commons/pagination}/page.d.ts +1 -1
- package/use-lunatic/commons/{page.js → pagination/page.js} +2 -2
- package/use-lunatic/commons/pagination/page.js.map +1 -0
- package/use-lunatic/hooks/use-page-has-response.js +36 -21
- package/use-lunatic/hooks/use-page-has-response.js.map +1 -1
- package/use-lunatic/hooks/useOverview.js +2 -2
- package/use-lunatic/hooks/useOverview.js.map +1 -1
- package/use-lunatic/props/getComponentTypeProps.d.ts +28 -26
- package/use-lunatic/props/getComponentTypeProps.js +2 -1
- package/use-lunatic/props/getComponentTypeProps.js.map +1 -1
- package/use-lunatic/props/propOptions.d.ts +9 -1
- package/use-lunatic/props/propOptions.js +57 -2
- package/use-lunatic/props/propOptions.js.map +1 -1
- package/use-lunatic/props/propOptions.spec.js +217 -55
- package/use-lunatic/props/propOptions.spec.js.map +1 -1
- package/use-lunatic/reducer/commons/auto-explore-loop.js +6 -2
- package/use-lunatic/reducer/commons/auto-explore-loop.js.map +1 -1
- package/use-lunatic/reducer/overview/overviewOnInit.d.ts +1 -2
- package/use-lunatic/reducer/overview/overviewOnInit.js +1 -1
- package/use-lunatic/reducer/overview/overviewOnInit.js.map +1 -1
- package/use-lunatic/reducer/reduce-go-next-page.js +4 -3
- package/use-lunatic/reducer/reduce-go-next-page.js.map +1 -1
- package/use-lunatic/reducer/reduce-go-previous-page.js +2 -2
- package/use-lunatic/reducer/reduce-go-previous-page.js.map +1 -1
- package/use-lunatic/reducer/reduce-go-to-page.js +2 -2
- package/use-lunatic/reducer/reduce-go-to-page.js.map +1 -1
- package/use-lunatic/reducer/reducerInitializer.js +2 -2
- package/use-lunatic/reducer/reducerInitializer.js.map +1 -1
- package/use-lunatic/type.d.ts +1 -1
- package/utils/cast.js +5 -2
- package/utils/cast.js.map +1 -1
- package/utils/getArticulationState.js +2 -1
- package/utils/getArticulationState.js.map +1 -1
- package/utils/number.js +4 -4
- package/utils/number.js.map +1 -1
- package/esm/use-lunatic/commons/check-loops.js.map +0 -1
- package/esm/use-lunatic/commons/check-pager.js.map +0 -1
- package/esm/use-lunatic/commons/create-map-pages.js.map +0 -1
- package/esm/use-lunatic/commons/is-First-last-page.js.map +0 -1
- package/esm/use-lunatic/commons/is-paginated-loop.js.map +0 -1
- package/esm/use-lunatic/commons/is-roundabout.js.map +0 -1
- package/esm/use-lunatic/commons/page-navigation.js.map +0 -1
- package/esm/use-lunatic/commons/page-navigation.spec.js.map +0 -1
- package/esm/use-lunatic/commons/page-tag.js.map +0 -1
- package/esm/use-lunatic/commons/page-tag.spec.js.map +0 -1
- package/esm/use-lunatic/commons/page.js.map +0 -1
- package/use-lunatic/commons/check-loops.js.map +0 -1
- package/use-lunatic/commons/check-pager.js.map +0 -1
- package/use-lunatic/commons/create-map-pages.js.map +0 -1
- package/use-lunatic/commons/is-First-last-page.js.map +0 -1
- package/use-lunatic/commons/is-paginated-loop.js.map +0 -1
- package/use-lunatic/commons/is-roundabout.js.map +0 -1
- package/use-lunatic/commons/page-navigation.js.map +0 -1
- package/use-lunatic/commons/page-navigation.spec.js.map +0 -1
- package/use-lunatic/commons/page-tag.js.map +0 -1
- package/use-lunatic/commons/page-tag.spec.js.map +0 -1
- package/use-lunatic/commons/page.js.map +0 -1
- /package/esm/use-lunatic/commons/{check-pager.js → pagination/check-pager.js} +0 -0
- /package/esm/use-lunatic/commons/{create-map-pages.js → pagination/create-map-pages.js} +0 -0
- /package/esm/use-lunatic/commons/{is-First-last-page.js → pagination/is-First-last-page.js} +0 -0
- /package/esm/use-lunatic/commons/{is-paginated-loop.js → pagination/is-paginated-loop.js} +0 -0
- /package/esm/use-lunatic/commons/{is-roundabout.js → pagination/is-roundabout.js} +0 -0
- /package/esm/use-lunatic/commons/{page-navigation.spec.d.ts → pagination/page-navigation.spec.d.ts} +0 -0
- /package/esm/use-lunatic/commons/{page-navigation.spec.js → pagination/page-navigation.spec.js} +0 -0
- /package/esm/use-lunatic/commons/{page-tag.spec.d.ts → pagination/page-tag.spec.d.ts} +0 -0
- /package/use-lunatic/commons/{check-pager.js → pagination/check-pager.js} +0 -0
- /package/use-lunatic/commons/{create-map-pages.js → pagination/create-map-pages.js} +0 -0
- /package/use-lunatic/commons/{is-First-last-page.js → pagination/is-First-last-page.js} +0 -0
- /package/use-lunatic/commons/{is-paginated-loop.js → pagination/is-paginated-loop.js} +0 -0
- /package/use-lunatic/commons/{is-roundabout.js → pagination/is-roundabout.js} +0 -0
- /package/use-lunatic/commons/{page-navigation.spec.d.ts → pagination/page-navigation.spec.d.ts} +0 -0
- /package/use-lunatic/commons/{page-navigation.spec.js → pagination/page-navigation.spec.js} +0 -0
- /package/use-lunatic/commons/{page-tag.spec.d.ts → pagination/page-tag.spec.d.ts} +0 -0
|
@@ -1,34 +1,25 @@
|
|
|
1
1
|
import type { LunaticComponentProps } from '../type';
|
|
2
|
-
import {
|
|
3
|
-
import React, { Fragment } from 'react';
|
|
2
|
+
import { Fragment } from 'react';
|
|
4
3
|
import { LunaticComponents } from '../LunaticComponents';
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
4
|
+
import { PairwiseMirror } from './PairwiseMirror';
|
|
5
|
+
import { filterCombinations, getCombinations } from './combinations';
|
|
7
6
|
|
|
8
|
-
export const PairwiseLinks = (
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
id,
|
|
13
|
-
getComponents,
|
|
14
|
-
}: LunaticComponentProps<'PairwiseLinks'>) => {
|
|
15
|
-
const nbRows = xAxisIterations * yAxisIterations;
|
|
7
|
+
export const PairwiseLinks = (
|
|
8
|
+
props: LunaticComponentProps<'PairwiseLinks'>
|
|
9
|
+
) => {
|
|
10
|
+
const { iteration, size, getComponents } = props;
|
|
16
11
|
|
|
17
|
-
if
|
|
18
|
-
|
|
12
|
+
// We only need to display a pairwise if there are at least 2 guys
|
|
13
|
+
if (size < 2) {
|
|
14
|
+
return;
|
|
19
15
|
}
|
|
20
16
|
|
|
21
|
-
const combinations = getCombinations(
|
|
17
|
+
const combinations = getCombinations(size);
|
|
22
18
|
|
|
23
19
|
return (
|
|
24
20
|
<>
|
|
25
|
-
<Declarations
|
|
26
|
-
type="AFTER_QUESTION_TEXT"
|
|
27
|
-
declarations={declarations}
|
|
28
|
-
id={id}
|
|
29
|
-
/>
|
|
30
21
|
{combinations
|
|
31
|
-
.filter((
|
|
22
|
+
.filter((combination) => filterCombinations({ combination, iteration }))
|
|
32
23
|
.map(([x, y]) => (
|
|
33
24
|
<LunaticComponents
|
|
34
25
|
key={`${x}-${y}`}
|
|
@@ -40,14 +31,15 @@ export const PairwiseLinks = ({
|
|
|
40
31
|
/>
|
|
41
32
|
))}
|
|
42
33
|
{combinations
|
|
43
|
-
.filter((
|
|
34
|
+
.filter((combination) =>
|
|
35
|
+
filterCombinations({ combination, iteration, isSymLink: true })
|
|
36
|
+
)
|
|
44
37
|
.map(([x, y]) => {
|
|
45
|
-
const components = getComponents(
|
|
38
|
+
const components = getComponents(x, y);
|
|
46
39
|
const firstComponent = components[0];
|
|
47
|
-
if (firstComponent
|
|
48
|
-
if (firstComponent.componentType !== 'Dropdown') {
|
|
40
|
+
if (firstComponent?.componentType !== 'Dropdown') {
|
|
49
41
|
return (
|
|
50
|
-
<div>
|
|
42
|
+
<div key={'PairwiseLinksLoop-error'}>
|
|
51
43
|
First child component of a pairwise link must be a dropdown
|
|
52
44
|
</div>
|
|
53
45
|
);
|
|
@@ -55,40 +47,9 @@ export const PairwiseLinks = ({
|
|
|
55
47
|
return (
|
|
56
48
|
<Fragment key={`${x}-${y}`}>
|
|
57
49
|
<PairwiseMirror {...firstComponent} />
|
|
58
|
-
<LunaticComponents
|
|
59
|
-
components={components.slice(1)}
|
|
60
|
-
componentProps={(props) => ({
|
|
61
|
-
...props,
|
|
62
|
-
id: `${props.id}-${x + 1}-${y + 1} `,
|
|
63
|
-
})}
|
|
64
|
-
/>
|
|
65
50
|
</Fragment>
|
|
66
51
|
);
|
|
67
52
|
})}
|
|
68
53
|
</>
|
|
69
54
|
);
|
|
70
55
|
};
|
|
71
|
-
|
|
72
|
-
const PairwiseMirror = ({
|
|
73
|
-
value,
|
|
74
|
-
options,
|
|
75
|
-
label,
|
|
76
|
-
}: LunaticComponentProps<'Dropdown'>) => {
|
|
77
|
-
const selectedOption = options?.find((o) => o.value === value);
|
|
78
|
-
if (!selectedOption) {
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
return (
|
|
82
|
-
<div className="lunatic lunatic-component lunatic-dropdown lunatic-combo-box-container default-style">
|
|
83
|
-
<Label>{label}</Label>
|
|
84
|
-
<div>{selectedOption?.label}</div>
|
|
85
|
-
</div>
|
|
86
|
-
);
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
const getCombinations = (
|
|
90
|
-
sizeX: number,
|
|
91
|
-
sizeY: number
|
|
92
|
-
): (readonly [number, number])[] => {
|
|
93
|
-
return times(sizeY, (y) => times(sizeX, (x) => [x, y] as const)).flat(1);
|
|
94
|
-
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import { Label } from '../shared/Label/Label';
|
|
2
|
+
import { LunaticComponentProps } from '../type';
|
|
3
|
+
|
|
4
|
+
export const PairwiseMirror = ({
|
|
5
|
+
value,
|
|
6
|
+
options,
|
|
7
|
+
label,
|
|
8
|
+
}: LunaticComponentProps<'Dropdown'>) => {
|
|
9
|
+
const selectedOption = options?.find((o) => o.value === value);
|
|
10
|
+
if (!selectedOption) {
|
|
11
|
+
return null;
|
|
12
|
+
}
|
|
13
|
+
return (
|
|
14
|
+
<div className="lunatic lunatic-component lunatic-dropdown lunatic-combo-box-container default-style">
|
|
15
|
+
<Label>{label}</Label>
|
|
16
|
+
<div>{selectedOption?.label}</div>
|
|
17
|
+
</div>
|
|
18
|
+
);
|
|
19
|
+
};
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import { describe, expect, it } from 'vitest';
|
|
2
|
+
import { filterCombinations, getCombinations } from './combinations';
|
|
3
|
+
|
|
4
|
+
describe('combinations utils', () => {
|
|
5
|
+
it('should create square combinations', () => {
|
|
6
|
+
expect(getCombinations(1)).toStrictEqual([[0, 0]]);
|
|
7
|
+
expect(getCombinations(2)).toStrictEqual([
|
|
8
|
+
[0, 0],
|
|
9
|
+
[1, 0],
|
|
10
|
+
[0, 1],
|
|
11
|
+
[1, 1],
|
|
12
|
+
]);
|
|
13
|
+
expect(getCombinations(3)).toStrictEqual([
|
|
14
|
+
[0, 0],
|
|
15
|
+
[1, 0],
|
|
16
|
+
[2, 0],
|
|
17
|
+
[0, 1],
|
|
18
|
+
[1, 1],
|
|
19
|
+
[2, 1],
|
|
20
|
+
[0, 2],
|
|
21
|
+
[1, 2],
|
|
22
|
+
[2, 2],
|
|
23
|
+
]);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
it('should filter combinations paiwise link in Loop', () => {
|
|
27
|
+
const combinations = getCombinations(3);
|
|
28
|
+
|
|
29
|
+
expect(
|
|
30
|
+
combinations.filter((combination) =>
|
|
31
|
+
filterCombinations({ combination, iteration: 0, isSymLink: false })
|
|
32
|
+
)
|
|
33
|
+
).toStrictEqual([
|
|
34
|
+
[1, 0],
|
|
35
|
+
[2, 0],
|
|
36
|
+
]);
|
|
37
|
+
|
|
38
|
+
expect(
|
|
39
|
+
combinations.filter((combination) =>
|
|
40
|
+
filterCombinations({ combination, iteration: 1, isSymLink: false })
|
|
41
|
+
)
|
|
42
|
+
).toStrictEqual([[2, 1]]);
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should filter combinations paiwise link not in Loop', () => {
|
|
46
|
+
const combinations = getCombinations(3);
|
|
47
|
+
expect(
|
|
48
|
+
combinations.filter((combination) =>
|
|
49
|
+
filterCombinations({
|
|
50
|
+
combination,
|
|
51
|
+
iteration: undefined,
|
|
52
|
+
isSymLink: false,
|
|
53
|
+
})
|
|
54
|
+
)
|
|
55
|
+
).toStrictEqual([
|
|
56
|
+
[1, 0],
|
|
57
|
+
[2, 0],
|
|
58
|
+
[2, 1],
|
|
59
|
+
]);
|
|
60
|
+
});
|
|
61
|
+
|
|
62
|
+
it('should filter combinations for readonly paiwise link in Loop', () => {
|
|
63
|
+
const combinations = getCombinations(3);
|
|
64
|
+
|
|
65
|
+
expect(
|
|
66
|
+
combinations.filter((combination) =>
|
|
67
|
+
filterCombinations({ combination, iteration: 0, isSymLink: true })
|
|
68
|
+
)
|
|
69
|
+
).toStrictEqual([]);
|
|
70
|
+
|
|
71
|
+
expect(
|
|
72
|
+
combinations.filter((combination) =>
|
|
73
|
+
filterCombinations({ combination, iteration: 1, isSymLink: true })
|
|
74
|
+
)
|
|
75
|
+
).toStrictEqual([[0, 1]]);
|
|
76
|
+
|
|
77
|
+
expect(
|
|
78
|
+
combinations.filter((combination) =>
|
|
79
|
+
filterCombinations({ combination, iteration: 2, isSymLink: true })
|
|
80
|
+
)
|
|
81
|
+
).toStrictEqual([
|
|
82
|
+
[0, 2],
|
|
83
|
+
[1, 2],
|
|
84
|
+
]);
|
|
85
|
+
});
|
|
86
|
+
|
|
87
|
+
it('should filter combinations for readonly paiwise link not in Loop', () => {
|
|
88
|
+
const combinations = getCombinations(3);
|
|
89
|
+
expect(
|
|
90
|
+
combinations.filter((combination) =>
|
|
91
|
+
filterCombinations({
|
|
92
|
+
combination,
|
|
93
|
+
iteration: undefined,
|
|
94
|
+
isSymLink: true,
|
|
95
|
+
})
|
|
96
|
+
)
|
|
97
|
+
).toStrictEqual([
|
|
98
|
+
[0, 1],
|
|
99
|
+
[0, 2],
|
|
100
|
+
[1, 2],
|
|
101
|
+
]);
|
|
102
|
+
});
|
|
103
|
+
});
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { times } from '../../utils/array';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Create square of combination
|
|
5
|
+
* @param size
|
|
6
|
+
* @returns all coodornate of matrix in list exemple for 2x2 matrix, return [[0,0],[0,1],[1,0],[1,1]]
|
|
7
|
+
*/
|
|
8
|
+
export const getCombinations = (
|
|
9
|
+
size: number
|
|
10
|
+
): (readonly [number, number])[] => {
|
|
11
|
+
return times(size, (y) => times(size, (x) => [x, y] as const)).flat(1);
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Filter combination of pairwise for display only necessary ones
|
|
16
|
+
* depending on whether we want to only display symlinks,
|
|
17
|
+
* or if we display only selected iterations (because we display pairwise in a loop).
|
|
18
|
+
* @param param: combination, current iteration (if in loop), isSymLink: indicate if we want to display symLink (for pairwise miror -> "lien symétriques")
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
export const filterCombinations = ({
|
|
22
|
+
combination,
|
|
23
|
+
iteration,
|
|
24
|
+
isSymLink = false,
|
|
25
|
+
}: {
|
|
26
|
+
combination: readonly [number, number];
|
|
27
|
+
iteration?: number;
|
|
28
|
+
isSymLink?: boolean;
|
|
29
|
+
}): boolean => {
|
|
30
|
+
const [x, y] = combination;
|
|
31
|
+
const base = isSymLink ? y > x : y < x;
|
|
32
|
+
if (iteration === undefined) return base;
|
|
33
|
+
return y === iteration && base;
|
|
34
|
+
};
|