@inseefr/lunatic 3.5.0-rc.3 → 3.5.1-rc.1743691949561
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/Datepicker/Datepicker.js +1 -1
- package/components/Datepicker/Datepicker.js.map +1 -1
- package/components/Duration/Duration.js +3 -2
- package/components/Duration/Duration.js.map +1 -1
- package/components/Duration/durationUtils.d.ts +0 -1
- package/components/Duration/durationUtils.js.map +1 -1
- package/components/Duration/getDurationFromValue.d.ts +3 -2
- package/components/Duration/getDurationFromValue.js.map +1 -1
- package/components/Input/Input.js +6 -3
- package/components/Input/Input.js.map +1 -1
- package/components/Input/Input.spec.js +25 -0
- package/components/Input/Input.spec.js.map +1 -1
- package/components/InputNumber/InputNumber.js +1 -1
- package/components/InputNumber/InputNumber.js.map +1 -1
- package/components/InputNumber/InputNumber.spec.js +9 -1
- package/components/InputNumber/InputNumber.spec.js.map +1 -1
- package/components/InputNumber/InputNumberThousand.d.ts +2 -1
- package/components/InputNumber/InputNumberThousand.js +8 -2
- package/components/InputNumber/InputNumberThousand.js.map +1 -1
- package/components/Loop/Loop.js +1 -1
- package/components/Loop/Loop.js.map +1 -1
- package/components/Loop/Loop.spec.d.ts +1 -0
- package/components/Loop/Loop.spec.js +39 -0
- package/components/Loop/Loop.spec.js.map +1 -0
- package/components/Roundabout/CustomRoundabout.d.ts +1 -1
- package/components/Roundabout/CustomRoundabout.js +4 -3
- package/components/Roundabout/CustomRoundabout.js.map +1 -1
- package/components/Roundabout/roundabout.spec.js +3 -1
- package/components/Roundabout/roundabout.spec.js.map +1 -1
- package/components/Textarea/Textarea.js +4 -1
- package/components/Textarea/Textarea.js.map +1 -1
- package/components/Textarea/Textarea.spec.js +13 -0
- package/components/Textarea/Textarea.spec.js.map +1 -1
- package/components/shared/CharactersCount/CharactersCount.d.ts +7 -0
- package/components/shared/CharactersCount/CharactersCount.js +20 -0
- package/components/shared/CharactersCount/CharactersCount.js.map +1 -0
- package/components/shared/CharactersCount/CharactersCount.spec.d.ts +1 -0
- package/components/shared/CharactersCount/CharactersCount.spec.js +28 -0
- package/components/shared/CharactersCount/CharactersCount.spec.js.map +1 -0
- package/components/shared/Label/Label.js +1 -1
- package/components/shared/Label/Label.js.map +1 -1
- package/components/shared/Label/Label.spec.js +11 -3
- package/components/shared/Label/Label.spec.js.map +1 -1
- package/components/shared/utils/getCharactersCountId.d.ts +4 -0
- package/components/shared/utils/getCharactersCountId.js +10 -0
- package/components/shared/utils/getCharactersCountId.js.map +1 -0
- package/components/type.d.ts +3 -3
- package/esm/components/Datepicker/Datepicker.js +1 -1
- package/esm/components/Datepicker/Datepicker.js.map +1 -1
- package/esm/components/Duration/Duration.js +3 -2
- package/esm/components/Duration/Duration.js.map +1 -1
- package/esm/components/Duration/durationUtils.d.ts +0 -1
- package/esm/components/Duration/durationUtils.js.map +1 -1
- package/esm/components/Duration/getDurationFromValue.d.ts +3 -2
- package/esm/components/Duration/getDurationFromValue.js.map +1 -1
- package/esm/components/Input/Input.js +6 -3
- package/esm/components/Input/Input.js.map +1 -1
- package/esm/components/Input/Input.spec.js +25 -0
- package/esm/components/Input/Input.spec.js.map +1 -1
- package/esm/components/InputNumber/InputNumber.js +1 -1
- package/esm/components/InputNumber/InputNumber.js.map +1 -1
- package/esm/components/InputNumber/InputNumber.spec.js +9 -1
- package/esm/components/InputNumber/InputNumber.spec.js.map +1 -1
- package/esm/components/InputNumber/InputNumberThousand.d.ts +2 -1
- package/esm/components/InputNumber/InputNumberThousand.js +8 -2
- package/esm/components/InputNumber/InputNumberThousand.js.map +1 -1
- package/esm/components/Loop/Loop.js +1 -1
- package/esm/components/Loop/Loop.js.map +1 -1
- package/esm/components/Loop/Loop.spec.d.ts +1 -0
- package/esm/components/Loop/Loop.spec.js +37 -0
- package/esm/components/Loop/Loop.spec.js.map +1 -0
- package/esm/components/Roundabout/CustomRoundabout.d.ts +1 -1
- package/esm/components/Roundabout/CustomRoundabout.js +4 -3
- package/esm/components/Roundabout/CustomRoundabout.js.map +1 -1
- package/esm/components/Roundabout/roundabout.spec.js +3 -1
- package/esm/components/Roundabout/roundabout.spec.js.map +1 -1
- package/esm/components/Textarea/Textarea.js +4 -1
- package/esm/components/Textarea/Textarea.js.map +1 -1
- package/esm/components/Textarea/Textarea.spec.js +13 -0
- package/esm/components/Textarea/Textarea.spec.js.map +1 -1
- package/esm/components/shared/CharactersCount/CharactersCount.d.ts +7 -0
- package/esm/components/shared/CharactersCount/CharactersCount.js +15 -0
- package/esm/components/shared/CharactersCount/CharactersCount.js.map +1 -0
- package/esm/components/shared/CharactersCount/CharactersCount.spec.d.ts +1 -0
- package/esm/components/shared/CharactersCount/CharactersCount.spec.js +26 -0
- package/esm/components/shared/CharactersCount/CharactersCount.spec.js.map +1 -0
- package/esm/components/shared/Label/Label.js +1 -1
- package/esm/components/shared/Label/Label.js.map +1 -1
- package/esm/components/shared/Label/Label.spec.js +11 -3
- package/esm/components/shared/Label/Label.spec.js.map +1 -1
- package/esm/components/shared/utils/getCharactersCountId.d.ts +4 -0
- package/esm/components/shared/utils/getCharactersCountId.js +7 -0
- package/esm/components/shared/utils/getCharactersCountId.js.map +1 -0
- package/esm/components/type.d.ts +3 -3
- package/esm/index.d.ts +0 -1
- package/esm/index.js +0 -1
- package/esm/index.js.map +1 -1
- package/esm/main.css +20 -0
- package/esm/main.css.map +1 -1
- package/esm/stories/overview/sourceWithHierarchy.json +5151 -0
- package/esm/tests/utils/lunatic.d.ts +0 -4
- package/esm/tests/utils/lunatic.js +0 -4
- package/esm/tests/utils/lunatic.js.map +1 -1
- package/esm/type.source.d.ts +6 -6
- package/esm/type.source.js +0 -1
- package/esm/type.source.js.map +1 -1
- package/esm/use-lunatic/commons/fill-components/fill-components.d.ts +2 -0
- package/esm/use-lunatic/commons/fill-components/fill-components.js +1 -1
- package/esm/use-lunatic/commons/fill-components/fill-components.js.map +1 -1
- package/esm/use-lunatic/commons/page.js +8 -0
- package/esm/use-lunatic/commons/page.js.map +1 -1
- package/esm/use-lunatic/commons/variables/behaviours/cleaning-behaviour.d.ts +1 -1
- package/esm/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js +111 -14
- package/esm/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js.map +1 -1
- package/esm/use-lunatic/commons/variables/behaviours/resizing-behaviour.js +3 -3
- package/esm/use-lunatic/commons/variables/behaviours/resizing-behaviour.js.map +1 -1
- package/esm/use-lunatic/commons/variables/get-questionnaire-data.js +0 -8
- package/esm/use-lunatic/commons/variables/get-questionnaire-data.js.map +1 -1
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.d.ts +2 -2
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.js +5 -3
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.js.map +1 -1
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.spec.js +181 -9
- package/esm/use-lunatic/commons/variables/lunatic-variables-store.spec.js.map +1 -1
- package/esm/use-lunatic/hooks/use-page-has-response.js +50 -35
- package/esm/use-lunatic/hooks/use-page-has-response.js.map +1 -1
- package/esm/use-lunatic/hooks/useOverview.d.ts +1 -1
- package/esm/use-lunatic/hooks/useOverview.js +19 -14
- package/esm/use-lunatic/hooks/useOverview.js.map +1 -1
- package/esm/use-lunatic/hooks/useOverview.spec.d.ts +1 -0
- package/esm/use-lunatic/hooks/useOverview.spec.js +38 -0
- package/esm/use-lunatic/hooks/useOverview.spec.js.map +1 -0
- package/esm/use-lunatic/props/getComponentTypeProps.d.ts +2 -1
- package/esm/use-lunatic/props/propOptions.d.ts +2 -1
- package/esm/use-lunatic/props/propOptions.js +23 -3
- package/esm/use-lunatic/props/propOptions.js.map +1 -1
- package/esm/use-lunatic/props/propOptions.spec.js +46 -5
- package/esm/use-lunatic/props/propOptions.spec.js.map +1 -1
- package/esm/use-lunatic/props/propValue.js +18 -6
- package/esm/use-lunatic/props/propValue.js.map +1 -1
- package/esm/use-lunatic/props/propValue.spec.js +97 -2
- package/esm/use-lunatic/props/propValue.spec.js.map +1 -1
- package/esm/use-lunatic/reducer/reducerInitializer.d.ts +2 -2
- package/esm/use-lunatic/reducer/reducerInitializer.js +25 -32
- package/esm/use-lunatic/reducer/reducerInitializer.js.map +1 -1
- package/esm/use-lunatic/test.utils.d.ts +2 -0
- package/esm/use-lunatic/test.utils.js +13 -0
- package/esm/use-lunatic/test.utils.js.map +1 -0
- package/esm/use-lunatic/type.d.ts +18 -8
- package/esm/use-lunatic/use-lunatic.d.ts +1 -2
- package/esm/use-lunatic/use-lunatic.js +2 -3
- package/esm/use-lunatic/use-lunatic.js.map +1 -1
- package/esm/utils/cast.d.ts +19 -0
- package/esm/utils/cast.js +63 -0
- package/esm/utils/cast.js.map +1 -0
- package/esm/utils/constants/variable-status.d.ts +0 -4
- package/esm/utils/constants/variable-status.js +0 -4
- package/esm/utils/constants/variable-status.js.map +1 -1
- package/esm/utils/variables.spec.js +0 -8
- package/esm/utils/variables.spec.js.map +1 -1
- package/index.d.ts +0 -1
- package/index.js +1 -3
- package/index.js.map +1 -1
- package/main.css +20 -0
- package/main.css.map +1 -1
- package/package.json +60 -69
- package/src/components/Datepicker/Datepicker.tsx +1 -1
- package/src/components/Datepicker/__snapshots__/Datepicker.spec.tsx.snap +2 -2
- package/src/components/Duration/Duration.test.tsx +52 -0
- package/src/components/Duration/Duration.tsx +17 -4
- package/src/components/Duration/durationUtils.ts +0 -2
- package/src/components/Duration/getDurationFromValue.ts +4 -3
- package/src/components/Input/Input.spec.tsx +34 -0
- package/src/components/Input/Input.tsx +26 -18
- package/src/components/Input/__snapshots__/Input.spec.tsx.snap +38 -19
- package/src/components/InputNumber/InputNumber.spec.tsx +15 -1
- package/src/components/InputNumber/InputNumber.tsx +1 -0
- package/src/components/InputNumber/InputNumberThousand.tsx +11 -1
- package/src/components/Loop/Loop.spec.tsx +77 -0
- package/src/components/Loop/Loop.tsx +1 -1
- package/src/components/RosterForLoop/__snapshots__/RosterForLoop.spec.tsx.snap +42 -20
- package/src/components/Roundabout/CustomRoundabout.tsx +13 -4
- package/src/components/Roundabout/roundabout.spec.tsx +3 -0
- package/src/components/Textarea/Textarea.spec.tsx +18 -0
- package/src/components/Textarea/Textarea.tsx +21 -13
- package/src/components/Textarea/__snapshots__/Textarea.spec.tsx.snap +21 -11
- package/src/components/shared/CharactersCount/CharactersCount.spec.tsx +31 -0
- package/src/components/shared/CharactersCount/CharactersCount.tsx +27 -0
- package/src/components/shared/Label/Label.spec.tsx +15 -3
- package/src/components/shared/Label/Label.tsx +1 -1
- package/src/components/shared/utils/getCharactersCountId.test.ts +14 -0
- package/src/components/shared/utils/getCharactersCountId.ts +6 -0
- package/src/components/type.ts +3 -2
- package/src/css/components/Input.scss +10 -0
- package/src/css/components/Roundabout.scss +10 -0
- package/src/index.ts +0 -1
- package/src/stories/accordion/source.json +1 -5
- package/src/stories/behaviour/cleaning/cleaning.stories.jsx +11 -0
- package/src/stories/behaviour/cleaning/loop.json +246 -0
- package/src/stories/behaviour/cleaning/source-loop.json +3 -15
- package/src/stories/behaviour/cleaning/source.json +2 -10
- package/src/stories/behaviour/controls/boucles-n.json +2 -10
- package/src/stories/behaviour/controls/loop.json +2 -10
- package/src/stories/behaviour/controls/roundabout.json +3 -15
- package/src/stories/behaviour/controls/simple-numeric.json +19 -95
- package/src/stories/behaviour/controls/simple.json +7 -35
- package/src/stories/behaviour/filter/dataLoop.json +0 -8
- package/src/stories/behaviour/filter/source.json +0 -12
- package/src/stories/behaviour/filter/sourceLoop.json +0 -12
- package/src/stories/behaviour/missing/source.json +12 -60
- package/src/stories/behaviour/others/V2_DeclarationsSimples.json +14 -70
- package/src/stories/behaviour/others/V2_MinMaxSum_Boucles.json +5 -25
- package/src/stories/behaviour/others/V2_QuestSimple_Boucles.json +107 -535
- package/src/stories/behaviour/others/V2_TCMRallyeGames.json +33 -165
- package/src/stories/behaviour/others/test-dylan.json +5 -25
- package/src/stories/behaviour/paste/source.json +1 -5
- package/src/stories/behaviour/performance/performance.stories.jsx +2 -2
- package/src/stories/behaviour/performance/source.json +4 -20
- package/src/stories/behaviour/resizing/source-resizing-cleaning.json +2 -10
- package/src/stories/behaviour/resizing/source.json +5 -25
- package/src/stories/checkbox-boolean/source.json +1 -5
- package/src/stories/checkbox-group/source.json +16 -80
- package/src/stories/checkbox-group/sourceCondition.json +3 -15
- package/src/stories/checkbox-group/sourceDetail.json +18 -90
- package/src/stories/checkbox-group/sourceLoop.json +2 -10
- package/src/stories/checkbox-one/source.json +1 -5
- package/src/stories/checkbox-one/sourceDetail.json +2 -10
- package/src/stories/date-picker/source.json +1 -5
- package/src/stories/declaration/source.json +2 -10
- package/src/stories/disabled/data.json +0 -16
- package/src/stories/disabled/source.json +7 -35
- package/src/stories/dropdown/data.json +2 -10
- package/src/stories/dropdown/source.json +2 -10
- package/src/stories/duration/mois.json +1 -5
- package/src/stories/duration/time.json +1 -5
- package/src/stories/filter-description/source-options.json +3 -15
- package/src/stories/input/source.json +1 -5
- package/src/stories/input-number/input-number.stories.jsx +5 -0
- package/src/stories/input-number/source-big-number.json +27 -0
- package/src/stories/input-number/source-euro.json +2 -6
- package/src/stories/input-number/source.json +1 -5
- package/src/stories/loop/source-bloc.json +2 -10
- package/src/stories/loop/source-paginated.json +2 -10
- package/src/stories/loop/source-roster.json +2 -10
- package/src/stories/loop/source-with-header.json +2 -10
- package/src/stories/overview/dataLoop.json +24 -120
- package/src/stories/overview/overview.stories.jsx +9 -0
- package/src/stories/overview/source.json +1 -5
- package/src/stories/overview/sourceLoop.json +24 -120
- package/src/stories/overview/sourceWithHierarchy.json +164 -820
- package/src/stories/pairwise/source.json +5 -25
- package/src/stories/question/source.json +2 -10
- package/src/stories/questionnaires/logement/data.json +0 -1288
- package/src/stories/questionnaires/logement/source-sequence.json +564 -2820
- package/src/stories/questionnaires/logement/source-sum.json +280 -1400
- package/src/stories/questionnaires/logement/source.json +564 -2820
- package/src/stories/questionnaires/recensement/source.json +106 -530
- package/src/stories/questionnaires/rp/source.json +8 -40
- package/src/stories/questionnaires/simpsons/source.json +104 -520
- package/src/stories/radio/source.json +1 -5
- package/src/stories/radio/sourceCondition.json +2 -10
- package/src/stories/radio/sourceDetail.json +2 -10
- package/src/stories/radio/sourceHorizontal.json +1 -5
- package/src/stories/roundabout/data1.json +0 -12
- package/src/stories/roundabout/data2.json +0 -16
- package/src/stories/roundabout/source.json +11 -35
- package/src/stories/suggester/source-arbitrary-response.json +6 -30
- package/src/stories/suggester/source-error.json +6 -30
- package/src/stories/suggester/source-multiline.json +0 -16
- package/src/stories/suggester/source-option-responses.json +5 -25
- package/src/stories/suggester/source.json +7 -35
- package/src/stories/summary/data.json +0 -16
- package/src/stories/summary/source.json +7 -35
- package/src/stories/switch/data-forced.json +2 -10
- package/src/stories/switch/source.json +4 -20
- package/src/stories/table/source-colspan.json +8 -40
- package/src/stories/table/table-dynamique.json +1 -5
- package/src/stories/text/source-roster.json +3 -15
- package/src/stories/text/source-table.json +9 -45
- package/src/stories/textarea/source.json +1 -5
- package/src/stories/utils/{SchemaValidator.tsx → SchemaValidator.jsx} +1 -1
- package/src/stories/utils/{orchestrator.tsx → orchestrator.jsx} +9 -13
- package/src/stories/utils/{overview.tsx → overview.jsx} +0 -2
- package/src/tests/utils/lunatic.ts +0 -4
- package/src/type.source.ts +8 -7
- package/src/use-lunatic/__snapshots__/use-lunatic.test.ts.snap +0 -1159
- package/src/use-lunatic/commons/fill-components/fill-components.ts +4 -1
- package/src/use-lunatic/commons/page.ts +10 -0
- package/src/use-lunatic/commons/variables/behaviours/cleaning-behaviour.ts +182 -24
- package/src/use-lunatic/commons/variables/behaviours/resizing-behaviour.ts +2 -5
- package/src/use-lunatic/commons/variables/get-questionnaire-data.ts +0 -12
- package/src/use-lunatic/commons/variables/lunatic-variables-store.spec.ts +207 -9
- package/src/use-lunatic/commons/variables/lunatic-variables-store.ts +7 -4
- package/src/use-lunatic/hooks/use-page-has-response.test.ts +200 -0
- package/src/use-lunatic/hooks/use-page-has-response.ts +67 -44
- package/src/use-lunatic/hooks/useOverview.spec.ts +42 -0
- package/src/use-lunatic/hooks/useOverview.ts +41 -18
- package/src/use-lunatic/props/propOptions.spec.ts +71 -5
- package/src/use-lunatic/props/propOptions.ts +23 -3
- package/src/use-lunatic/props/propValue.spec.ts +105 -2
- package/src/use-lunatic/props/propValue.ts +26 -8
- package/src/use-lunatic/reducer/reducerInitializer.tsx +31 -41
- package/src/use-lunatic/test.utils.ts +17 -0
- package/src/use-lunatic/type.ts +18 -8
- package/src/use-lunatic/use-lunatic.test.ts +15 -44
- package/src/use-lunatic/use-lunatic.ts +7 -7
- package/src/utils/cast.ts +67 -0
- package/src/utils/constants/variable-status.ts +0 -4
- package/src/utils/variables.spec.ts +0 -8
- package/stories/overview/sourceWithHierarchy.json +5151 -0
- package/tests/utils/lunatic.d.ts +0 -4
- package/tests/utils/lunatic.js +0 -4
- package/tests/utils/lunatic.js.map +1 -1
- package/tsconfig.build.tsbuildinfo +1 -1
- package/type.source.d.ts +6 -6
- package/type.source.js +0 -1
- package/type.source.js.map +1 -1
- package/use-lunatic/commons/fill-components/fill-components.d.ts +2 -0
- package/use-lunatic/commons/fill-components/fill-components.js +1 -1
- package/use-lunatic/commons/fill-components/fill-components.js.map +1 -1
- package/use-lunatic/commons/page.js +8 -0
- package/use-lunatic/commons/page.js.map +1 -1
- package/use-lunatic/commons/variables/behaviours/cleaning-behaviour.d.ts +1 -1
- package/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js +111 -14
- package/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js.map +1 -1
- package/use-lunatic/commons/variables/behaviours/resizing-behaviour.js +3 -3
- package/use-lunatic/commons/variables/behaviours/resizing-behaviour.js.map +1 -1
- package/use-lunatic/commons/variables/get-questionnaire-data.js +0 -8
- package/use-lunatic/commons/variables/get-questionnaire-data.js.map +1 -1
- package/use-lunatic/commons/variables/lunatic-variables-store.d.ts +2 -2
- package/use-lunatic/commons/variables/lunatic-variables-store.js +5 -3
- package/use-lunatic/commons/variables/lunatic-variables-store.js.map +1 -1
- package/use-lunatic/commons/variables/lunatic-variables-store.spec.js +204 -9
- package/use-lunatic/commons/variables/lunatic-variables-store.spec.js.map +1 -1
- package/use-lunatic/hooks/use-page-has-response.js +49 -34
- package/use-lunatic/hooks/use-page-has-response.js.map +1 -1
- package/use-lunatic/hooks/useOverview.d.ts +1 -1
- package/use-lunatic/hooks/useOverview.js +19 -14
- package/use-lunatic/hooks/useOverview.js.map +1 -1
- package/use-lunatic/hooks/useOverview.spec.d.ts +1 -0
- package/use-lunatic/hooks/useOverview.spec.js +43 -0
- package/use-lunatic/hooks/useOverview.spec.js.map +1 -0
- package/use-lunatic/props/getComponentTypeProps.d.ts +2 -1
- package/use-lunatic/props/propOptions.d.ts +2 -1
- package/use-lunatic/props/propOptions.js +23 -3
- package/use-lunatic/props/propOptions.js.map +1 -1
- package/use-lunatic/props/propOptions.spec.js +46 -5
- package/use-lunatic/props/propOptions.spec.js.map +1 -1
- package/use-lunatic/props/propValue.js +18 -6
- package/use-lunatic/props/propValue.js.map +1 -1
- package/use-lunatic/props/propValue.spec.js +97 -2
- package/use-lunatic/props/propValue.spec.js.map +1 -1
- package/use-lunatic/reducer/reducerInitializer.d.ts +2 -2
- package/use-lunatic/reducer/reducerInitializer.js +25 -32
- package/use-lunatic/reducer/reducerInitializer.js.map +1 -1
- package/use-lunatic/test.utils.d.ts +2 -0
- package/use-lunatic/test.utils.js +17 -0
- package/use-lunatic/test.utils.js.map +1 -0
- package/use-lunatic/type.d.ts +18 -8
- package/use-lunatic/use-lunatic.d.ts +1 -2
- package/use-lunatic/use-lunatic.js +2 -3
- package/use-lunatic/use-lunatic.js.map +1 -1
- package/utils/cast.d.ts +19 -0
- package/utils/cast.js +70 -0
- package/utils/cast.js.map +1 -0
- package/utils/constants/variable-status.d.ts +0 -4
- package/utils/constants/variable-status.js +1 -5
- package/utils/constants/variable-status.js.map +1 -1
- package/utils/variables.spec.js +0 -8
- package/utils/variables.spec.js.map +1 -1
- package/constants/component-types.d.ts +0 -1
- package/constants/component-types.js +0 -5
- package/constants/component-types.js.map +0 -1
- package/constants/declarations.d.ts +0 -9
- package/constants/declarations.js +0 -15
- package/constants/declarations.js.map +0 -1
- package/constants/event-types.d.ts +0 -10
- package/constants/event-types.js +0 -16
- package/constants/event-types.js.map +0 -1
- package/constants/index.d.ts +0 -5
- package/constants/index.js +0 -22
- package/constants/index.js.map +0 -1
- package/constants/indexedDBStore.d.ts +0 -21
- package/constants/indexedDBStore.js +0 -22
- package/constants/indexedDBStore.js.map +0 -1
- package/constants/supported-preferences.d.ts +0 -1
- package/constants/supported-preferences.js +0 -36
- package/constants/supported-preferences.js.map +0 -1
- package/constants/value-types.d.ts +0 -5
- package/constants/value-types.js +0 -9
- package/constants/value-types.js.map +0 -1
- package/constants/variable-types.d.ts +0 -2
- package/constants/variable-types.js +0 -8
- package/constants/variable-types.js.map +0 -1
- package/esm/constants/component-types.d.ts +0 -1
- package/esm/constants/component-types.js +0 -2
- package/esm/constants/component-types.js.map +0 -1
- package/esm/constants/declarations.d.ts +0 -9
- package/esm/constants/declarations.js +0 -12
- package/esm/constants/declarations.js.map +0 -1
- package/esm/constants/event-types.d.ts +0 -10
- package/esm/constants/event-types.js +0 -13
- package/esm/constants/event-types.js.map +0 -1
- package/esm/constants/index.d.ts +0 -5
- package/esm/constants/index.js +0 -6
- package/esm/constants/index.js.map +0 -1
- package/esm/constants/indexedDBStore.d.ts +0 -21
- package/esm/constants/indexedDBStore.js +0 -19
- package/esm/constants/indexedDBStore.js.map +0 -1
- package/esm/constants/supported-preferences.d.ts +0 -1
- package/esm/constants/supported-preferences.js +0 -10
- package/esm/constants/supported-preferences.js.map +0 -1
- package/esm/constants/value-types.d.ts +0 -5
- package/esm/constants/value-types.js +0 -6
- package/esm/constants/value-types.js.map +0 -1
- package/esm/constants/variable-types.d.ts +0 -2
- package/esm/constants/variable-types.js +0 -5
- package/esm/constants/variable-types.js.map +0 -1
- package/esm/utils/getArticulation.d.ts +0 -58
- package/esm/utils/getArticulation.js +0 -78
- package/esm/utils/getArticulation.js.map +0 -1
- package/src/constants/component-types.ts +0 -1
- package/src/constants/declarations.ts +0 -14
- package/src/constants/event-types.ts +0 -13
- package/src/constants/index.ts +0 -5
- package/src/constants/indexedDBStore.ts +0 -20
- package/src/constants/supported-preferences.ts +0 -10
- package/src/constants/value-types.ts +0 -5
- package/src/constants/variable-types.ts +0 -4
- package/src/stories/behaviour/articulation/articulation.stories.tsx +0 -108
- package/src/stories/behaviour/articulation/roundabout.json +0 -348
- package/src/utils/getArticulation.ts +0 -117
- package/utils/getArticulation.d.ts +0 -58
- package/utils/getArticulation.js +0 -77
- package/utils/getArticulation.js.map +0 -1
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { describe, expect, it, vi } from 'vitest';
|
|
2
|
+
import { usePageHasResponse } from './use-page-has-response';
|
|
3
|
+
import { type LunaticComponentProps } from '../../components/type';
|
|
4
|
+
import { renderHook } from '@testing-library/react';
|
|
5
|
+
|
|
6
|
+
const defaultComponentValues = {
|
|
7
|
+
id: 'a',
|
|
8
|
+
value: null,
|
|
9
|
+
handleChanges: vi.fn(),
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
describe('usePageHasResponse', () => {
|
|
13
|
+
it('should be true when there are no components', () => {
|
|
14
|
+
const components: LunaticComponentProps[] = [];
|
|
15
|
+
const { result } = renderHook(() =>
|
|
16
|
+
usePageHasResponse(components, vi.fn())
|
|
17
|
+
);
|
|
18
|
+
expect(result.current()).toBeTruthy();
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
it('should be false when there is no value', () => {
|
|
22
|
+
const components: LunaticComponentProps[] = [
|
|
23
|
+
{ ...defaultComponentValues, componentType: 'Text' },
|
|
24
|
+
];
|
|
25
|
+
const { result } = renderHook(() =>
|
|
26
|
+
usePageHasResponse(components, vi.fn())
|
|
27
|
+
);
|
|
28
|
+
expect(result.current()).toBeFalsy();
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should be true when there is a value', () => {
|
|
32
|
+
const components: LunaticComponentProps[] = [
|
|
33
|
+
{
|
|
34
|
+
...defaultComponentValues,
|
|
35
|
+
componentType: 'Text',
|
|
36
|
+
value: 'my awesome value',
|
|
37
|
+
},
|
|
38
|
+
];
|
|
39
|
+
const { result } = renderHook(() =>
|
|
40
|
+
usePageHasResponse(components, vi.fn())
|
|
41
|
+
);
|
|
42
|
+
expect(result.current()).toBeTruthy();
|
|
43
|
+
});
|
|
44
|
+
|
|
45
|
+
it('should be true for a Question component', () => {
|
|
46
|
+
const components: LunaticComponentProps[] = [
|
|
47
|
+
{
|
|
48
|
+
...defaultComponentValues,
|
|
49
|
+
componentType: 'Question',
|
|
50
|
+
components: [
|
|
51
|
+
{
|
|
52
|
+
...defaultComponentValues,
|
|
53
|
+
componentType: 'Text',
|
|
54
|
+
},
|
|
55
|
+
],
|
|
56
|
+
value: { t1: 'my awesome value' },
|
|
57
|
+
},
|
|
58
|
+
];
|
|
59
|
+
const { result } = renderHook(() =>
|
|
60
|
+
usePageHasResponse(components, vi.fn())
|
|
61
|
+
);
|
|
62
|
+
expect(result.current()).toBeTruthy();
|
|
63
|
+
});
|
|
64
|
+
|
|
65
|
+
it('should be true when there is an arbitrary response', () => {
|
|
66
|
+
const components: LunaticComponentProps[] = [
|
|
67
|
+
{
|
|
68
|
+
...defaultComponentValues,
|
|
69
|
+
componentType: 'Suggester',
|
|
70
|
+
allowArbitrary: true,
|
|
71
|
+
arbitraryValue: 'my arbitrary value',
|
|
72
|
+
} as any,
|
|
73
|
+
];
|
|
74
|
+
const { result } = renderHook(() =>
|
|
75
|
+
usePageHasResponse(components, vi.fn())
|
|
76
|
+
);
|
|
77
|
+
expect(result.current()).toBeTruthy();
|
|
78
|
+
});
|
|
79
|
+
|
|
80
|
+
it('should be true when there is a missing response', () => {
|
|
81
|
+
const components: LunaticComponentProps[] = [
|
|
82
|
+
{
|
|
83
|
+
...defaultComponentValues,
|
|
84
|
+
componentType: 'Text',
|
|
85
|
+
missingResponse: { name: 'a_MISSING', value: 'my missing value' },
|
|
86
|
+
},
|
|
87
|
+
];
|
|
88
|
+
const { result } = renderHook(() =>
|
|
89
|
+
usePageHasResponse(components, vi.fn())
|
|
90
|
+
);
|
|
91
|
+
expect(result.current()).toBeTruthy();
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
it('should be true for a QCM table', () => {
|
|
95
|
+
const mockExecuteExpression = vi.fn();
|
|
96
|
+
mockExecuteExpression.mockReturnValueOnce('my value');
|
|
97
|
+
const components: LunaticComponentProps[] = [
|
|
98
|
+
{
|
|
99
|
+
...defaultComponentValues,
|
|
100
|
+
componentType: 'Table',
|
|
101
|
+
body: [
|
|
102
|
+
[
|
|
103
|
+
{
|
|
104
|
+
...defaultComponentValues,
|
|
105
|
+
id: 't1',
|
|
106
|
+
componentType: 'CheckboxBoolean',
|
|
107
|
+
response: { name: 't1' },
|
|
108
|
+
},
|
|
109
|
+
],
|
|
110
|
+
],
|
|
111
|
+
header: [{ label: 'my label' }],
|
|
112
|
+
executeExpression: vi.fn(),
|
|
113
|
+
iteration: 0,
|
|
114
|
+
value: {},
|
|
115
|
+
},
|
|
116
|
+
];
|
|
117
|
+
const { result } = renderHook(() =>
|
|
118
|
+
usePageHasResponse(components, mockExecuteExpression)
|
|
119
|
+
);
|
|
120
|
+
expect(result.current()).toBeTruthy();
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
it('should be true for a QCM table in a Question', () => {
|
|
124
|
+
const mockExecuteExpression = vi.fn();
|
|
125
|
+
mockExecuteExpression.mockReturnValueOnce('my value');
|
|
126
|
+
const components: LunaticComponentProps[] = [
|
|
127
|
+
{
|
|
128
|
+
...defaultComponentValues,
|
|
129
|
+
componentType: 'Question',
|
|
130
|
+
components: [
|
|
131
|
+
{
|
|
132
|
+
...defaultComponentValues,
|
|
133
|
+
componentType: 'Table',
|
|
134
|
+
body: [
|
|
135
|
+
[
|
|
136
|
+
{
|
|
137
|
+
...defaultComponentValues,
|
|
138
|
+
id: 't1',
|
|
139
|
+
componentType: 'CheckboxBoolean',
|
|
140
|
+
response: { name: 't1' },
|
|
141
|
+
},
|
|
142
|
+
],
|
|
143
|
+
],
|
|
144
|
+
header: [{ label: 'my label' }],
|
|
145
|
+
executeExpression: vi.fn(),
|
|
146
|
+
iteration: 0,
|
|
147
|
+
value: { t1: true },
|
|
148
|
+
},
|
|
149
|
+
],
|
|
150
|
+
value: {},
|
|
151
|
+
},
|
|
152
|
+
];
|
|
153
|
+
const { result } = renderHook(() =>
|
|
154
|
+
usePageHasResponse(components, mockExecuteExpression)
|
|
155
|
+
);
|
|
156
|
+
expect(result.current()).toBeTruthy();
|
|
157
|
+
});
|
|
158
|
+
});
|
|
159
|
+
|
|
160
|
+
it('should be true for a loop component with values', () => {
|
|
161
|
+
const mockExecuteExpression = vi.fn();
|
|
162
|
+
mockExecuteExpression.mockReturnValueOnce('my value');
|
|
163
|
+
|
|
164
|
+
const values = {
|
|
165
|
+
VOTREPRENO: ['Alice', 'Bob', 'Charlie'],
|
|
166
|
+
VOTREAGE: [22, 30, 40],
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const components = [
|
|
170
|
+
{
|
|
171
|
+
...defaultComponentValues,
|
|
172
|
+
componentType: 'Loop',
|
|
173
|
+
components: [
|
|
174
|
+
{
|
|
175
|
+
...defaultComponentValues,
|
|
176
|
+
componentType: 'Question',
|
|
177
|
+
components: [
|
|
178
|
+
{
|
|
179
|
+
...defaultComponentValues,
|
|
180
|
+
componentType: 'Input',
|
|
181
|
+
response: { name: 'VOTREPRENO' },
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
...defaultComponentValues,
|
|
185
|
+
componentType: 'InputNumber',
|
|
186
|
+
response: { name: 'VOTREAGE' },
|
|
187
|
+
},
|
|
188
|
+
],
|
|
189
|
+
},
|
|
190
|
+
],
|
|
191
|
+
value: values,
|
|
192
|
+
},
|
|
193
|
+
] as any as LunaticComponentProps[];
|
|
194
|
+
|
|
195
|
+
const { result } = renderHook(() =>
|
|
196
|
+
usePageHasResponse(components, mockExecuteExpression)
|
|
197
|
+
);
|
|
198
|
+
|
|
199
|
+
expect(result.current()).toBeTruthy();
|
|
200
|
+
});
|
|
@@ -11,59 +11,82 @@ export function usePageHasResponse(
|
|
|
11
11
|
executeExpression: LunaticReducerState['executeExpression']
|
|
12
12
|
): () => boolean {
|
|
13
13
|
return useCallback(() => {
|
|
14
|
-
|
|
14
|
+
return hasOneResponse(components, executeExpression);
|
|
15
|
+
}, [components, executeExpression]);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
function hasOneResponse(
|
|
19
|
+
components: LunaticComponentProps[],
|
|
20
|
+
executeExpression: LunaticReducerState['executeExpression']
|
|
21
|
+
): boolean {
|
|
22
|
+
if (!Array.isArray(components) || components.length === 0) {
|
|
23
|
+
return true;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
for (const component of components) {
|
|
27
|
+
// Some components are considered as "filled" by default
|
|
28
|
+
// We assume they are not in the same page has other components
|
|
29
|
+
if (
|
|
30
|
+
['PairwiseLinks', 'Roundabout', 'Sequence', 'Subsequence'].includes(
|
|
31
|
+
component.componentType ?? ''
|
|
32
|
+
)
|
|
33
|
+
) {
|
|
15
34
|
return true;
|
|
16
35
|
}
|
|
17
36
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
return true;
|
|
27
|
-
}
|
|
37
|
+
// We have a missing response for this component
|
|
38
|
+
if (
|
|
39
|
+
'missingResponse' in component &&
|
|
40
|
+
component.missingResponse &&
|
|
41
|
+
component.missingResponse.value
|
|
42
|
+
) {
|
|
43
|
+
return true;
|
|
44
|
+
}
|
|
28
45
|
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
component.missingResponse.value
|
|
34
|
-
) {
|
|
35
|
-
return true;
|
|
36
|
-
}
|
|
46
|
+
// We have an arbitrary response for this component
|
|
47
|
+
if ('arbitraryValue' in component && component.arbitraryValue) {
|
|
48
|
+
return true;
|
|
49
|
+
}
|
|
37
50
|
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
51
|
+
// For Table, we have to extract components from its body and apply isSubComponentsEmpty function
|
|
52
|
+
if (component.componentType === 'Table') {
|
|
53
|
+
// Body is array for array (row), each "cell" could be an Label or Component, so we filter array.
|
|
54
|
+
const childrenComponent = component.body.reduce((_, row) => {
|
|
55
|
+
const componentsInRow = row.filter(
|
|
56
|
+
(cell) => isObject(cell) && 'componentType' in cell
|
|
57
|
+
);
|
|
58
|
+
return [..._, ...componentsInRow];
|
|
59
|
+
}, [] as LunaticComponentProps[]);
|
|
60
|
+
return !isSubComponentsEmpty(childrenComponent, executeExpression);
|
|
61
|
+
}
|
|
49
62
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
63
|
+
// We found a value in one of the root component. Used for Loop
|
|
64
|
+
if ('value' in component && !isEmpty(component.value)) {
|
|
65
|
+
return true;
|
|
66
|
+
}
|
|
54
67
|
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
)
|
|
61
|
-
|
|
62
|
-
|
|
68
|
+
// For Question, we need to check subcomponents
|
|
69
|
+
if (
|
|
70
|
+
component.componentType === 'Question' &&
|
|
71
|
+
'components' in component &&
|
|
72
|
+
Array.isArray(component.components) &&
|
|
73
|
+
hasOneResponse(component.components, executeExpression)
|
|
74
|
+
) {
|
|
75
|
+
return true;
|
|
63
76
|
}
|
|
64
77
|
|
|
65
|
-
|
|
66
|
-
|
|
78
|
+
// For rosterForLoop we need to inspect child components
|
|
79
|
+
if (
|
|
80
|
+
component.componentType === 'RosterForLoop' &&
|
|
81
|
+
'components' in component &&
|
|
82
|
+
Array.isArray(component.components) &&
|
|
83
|
+
!isSubComponentsEmpty(component.components, executeExpression)
|
|
84
|
+
) {
|
|
85
|
+
return true;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
return false;
|
|
67
90
|
}
|
|
68
91
|
|
|
69
92
|
/**
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { renderHook } from '@testing-library/react';
|
|
2
|
+
import { describe, expect, it } from 'vitest';
|
|
3
|
+
import source from '../../stories/overview/sourceWithHierarchy.json';
|
|
4
|
+
import { useLunatic } from '../use-lunatic';
|
|
5
|
+
import { dataFromObject } from '../test.utils';
|
|
6
|
+
|
|
7
|
+
describe('use-overview test with useLunatic()', () => {
|
|
8
|
+
it('should initialize correctly with disableFilters: false (without data)', () => {
|
|
9
|
+
const params = [
|
|
10
|
+
source as any,
|
|
11
|
+
dataFromObject({}),
|
|
12
|
+
{ withOverview: true },
|
|
13
|
+
] as const;
|
|
14
|
+
const { result } = renderHook(() => useLunatic(...params));
|
|
15
|
+
expect(result.current.overview.length).toBe(3);
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('should initialize correctly with disableFilters: false (with data)', () => {
|
|
19
|
+
const params = [
|
|
20
|
+
source as any,
|
|
21
|
+
dataFromObject({
|
|
22
|
+
READY: true,
|
|
23
|
+
}),
|
|
24
|
+
{ withOverview: true },
|
|
25
|
+
] as const;
|
|
26
|
+
|
|
27
|
+
const { result } = renderHook(() => useLunatic(...params));
|
|
28
|
+
expect(result.current.overview.length).toBe(9);
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
it('should initialize correctly with disableFilters: true (without data)', () => {
|
|
32
|
+
const params = [
|
|
33
|
+
source as any,
|
|
34
|
+
dataFromObject({}),
|
|
35
|
+
{ withOverview: true, disableFilters: true },
|
|
36
|
+
] as const;
|
|
37
|
+
|
|
38
|
+
const { result } = renderHook(() => useLunatic(...params));
|
|
39
|
+
// All elements have to be presents
|
|
40
|
+
expect(result.current.overview.length).toBe(9);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type {
|
|
2
|
+
LunaticOptions,
|
|
2
3
|
LunaticOverviewItem,
|
|
3
4
|
LunaticReducerState,
|
|
4
5
|
PageTag,
|
|
@@ -25,13 +26,23 @@ export const useOverview = (
|
|
|
25
26
|
overview,
|
|
26
27
|
executeExpression,
|
|
27
28
|
pager,
|
|
28
|
-
|
|
29
|
+
options,
|
|
30
|
+
}: Pick<
|
|
31
|
+
LunaticReducerState,
|
|
32
|
+
'executeExpression' | 'overview' | 'pager' | 'options'
|
|
33
|
+
>,
|
|
29
34
|
deps: DependencyList
|
|
30
35
|
) => {
|
|
31
36
|
return useMemo(
|
|
32
|
-
() =>
|
|
37
|
+
() =>
|
|
38
|
+
interpretOverview(
|
|
39
|
+
overview,
|
|
40
|
+
executeExpression,
|
|
41
|
+
pager,
|
|
42
|
+
options.disableFilters
|
|
43
|
+
),
|
|
33
44
|
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
34
|
-
[...deps, overview]
|
|
45
|
+
[...deps, overview, options.disableFilters]
|
|
35
46
|
);
|
|
36
47
|
};
|
|
37
48
|
|
|
@@ -41,11 +52,16 @@ export const useOverview = (
|
|
|
41
52
|
const interpretOverview = (
|
|
42
53
|
overviewItems: LunaticOverviewItem[],
|
|
43
54
|
executeExpression: LunaticReducerState['executeExpression'],
|
|
44
|
-
pager?: LunaticReducerState['pager']
|
|
55
|
+
pager?: LunaticReducerState['pager'],
|
|
56
|
+
disableFilters?: LunaticOptions['disableFilters']
|
|
45
57
|
) => {
|
|
46
58
|
// Flat structure of the overview
|
|
47
59
|
let items = overviewItems.reduce(
|
|
48
|
-
(acc, item) =>
|
|
60
|
+
(acc, item) =>
|
|
61
|
+
interpretOverviewItem(acc, item, executeExpression, {
|
|
62
|
+
pager,
|
|
63
|
+
disableFilters,
|
|
64
|
+
}),
|
|
49
65
|
[] as InterpretedLunaticOverviewItem[]
|
|
50
66
|
);
|
|
51
67
|
// Sort using the page logic
|
|
@@ -77,7 +93,11 @@ const interpretOverviewItem = (
|
|
|
77
93
|
items: InterpretedLunaticOverviewItem[],
|
|
78
94
|
item: LunaticOverviewItem,
|
|
79
95
|
executeExpression: LunaticReducerState['executeExpression'],
|
|
80
|
-
|
|
96
|
+
state: {
|
|
97
|
+
pager?: LunaticReducerState['pager'];
|
|
98
|
+
disableFilters?: LunaticOptions['disableFilters'];
|
|
99
|
+
},
|
|
100
|
+
|
|
81
101
|
iteration?: number
|
|
82
102
|
): InterpretedLunaticOverviewItem[] => {
|
|
83
103
|
// We reached a loop item, we need to add it multiple time
|
|
@@ -85,19 +105,21 @@ const interpretOverviewItem = (
|
|
|
85
105
|
const iterations = executeExpression<number>(item.iterations) ?? 0;
|
|
86
106
|
return Array.from({ length: iterations }).reduce(
|
|
87
107
|
(acc: InterpretedLunaticOverviewItem[], _, k) => {
|
|
88
|
-
return interpretOverviewItem(acc, item, executeExpression,
|
|
108
|
+
return interpretOverviewItem(acc, item, executeExpression, state, k);
|
|
89
109
|
},
|
|
90
110
|
items
|
|
91
111
|
);
|
|
92
112
|
}
|
|
93
113
|
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
114
|
+
// if disableFilters is set to true, item are visible and reached by default
|
|
115
|
+
const isVisible = (() => {
|
|
116
|
+
if (state.disableFilters || !item.conditionFilter) return true;
|
|
117
|
+
return Boolean(
|
|
118
|
+
executeExpression(item.conditionFilter, {
|
|
119
|
+
iteration: iteration,
|
|
120
|
+
})
|
|
121
|
+
);
|
|
122
|
+
})();
|
|
101
123
|
|
|
102
124
|
if (!isVisible) {
|
|
103
125
|
return items;
|
|
@@ -106,6 +128,10 @@ const interpretOverviewItem = (
|
|
|
106
128
|
// Append the item to the list of items
|
|
107
129
|
const page =
|
|
108
130
|
`${item.pageTag}${iteration !== undefined ? `#${iteration + 1}` : ''}` as PageTag;
|
|
131
|
+
|
|
132
|
+
const reached =
|
|
133
|
+
pageTagComparator(state.pager ? getPageTag(state.pager) : '-1', page) >= 0;
|
|
134
|
+
|
|
109
135
|
return [
|
|
110
136
|
...items,
|
|
111
137
|
{
|
|
@@ -116,10 +142,7 @@ const interpretOverviewItem = (
|
|
|
116
142
|
? executeExpression(item.description, { iteration })
|
|
117
143
|
: undefined,
|
|
118
144
|
children: [],
|
|
119
|
-
reached:
|
|
120
|
-
pageTagComparator(pager ? getPageTag(pager) : '-1', page) >= 0
|
|
121
|
-
? true
|
|
122
|
-
: false,
|
|
145
|
+
reached: reached,
|
|
123
146
|
page: page,
|
|
124
147
|
current: false,
|
|
125
148
|
},
|
|
@@ -26,6 +26,7 @@ describe('getOptionsProp()', () => {
|
|
|
26
26
|
],
|
|
27
27
|
} satisfies DeepTranslateExpression<LunaticComponentDefinition>;
|
|
28
28
|
let mockChange: LunaticChangesHandler;
|
|
29
|
+
const mockLogger = vi.fn();
|
|
29
30
|
|
|
30
31
|
beforeEach(() => {
|
|
31
32
|
mockChange = vi.fn();
|
|
@@ -40,7 +41,8 @@ describe('getOptionsProp()', () => {
|
|
|
40
41
|
variables,
|
|
41
42
|
mockChange,
|
|
42
43
|
undefined,
|
|
43
|
-
undefined
|
|
44
|
+
undefined,
|
|
45
|
+
mockLogger
|
|
44
46
|
);
|
|
45
47
|
expect(options[1].checked).toBe(false);
|
|
46
48
|
variables.set('O2', true);
|
|
@@ -49,7 +51,8 @@ describe('getOptionsProp()', () => {
|
|
|
49
51
|
variables,
|
|
50
52
|
mockChange,
|
|
51
53
|
undefined,
|
|
52
|
-
undefined
|
|
54
|
+
undefined,
|
|
55
|
+
mockLogger
|
|
53
56
|
);
|
|
54
57
|
expect(options[1].checked).toBe(true);
|
|
55
58
|
});
|
|
@@ -61,7 +64,8 @@ describe('getOptionsProp()', () => {
|
|
|
61
64
|
variables,
|
|
62
65
|
mockChange,
|
|
63
66
|
0,
|
|
64
|
-
undefined
|
|
67
|
+
undefined,
|
|
68
|
+
mockLogger
|
|
65
69
|
);
|
|
66
70
|
expect(
|
|
67
71
|
options.filter((o) => o.checked),
|
|
@@ -74,7 +78,8 @@ describe('getOptionsProp()', () => {
|
|
|
74
78
|
variables,
|
|
75
79
|
mockChange,
|
|
76
80
|
0,
|
|
77
|
-
undefined
|
|
81
|
+
undefined,
|
|
82
|
+
mockLogger
|
|
78
83
|
);
|
|
79
84
|
expect(options[0].checked).toBe(true);
|
|
80
85
|
expect(options[1].checked).toBe(false);
|
|
@@ -87,12 +92,73 @@ describe('getOptionsProp()', () => {
|
|
|
87
92
|
variables,
|
|
88
93
|
mockChange,
|
|
89
94
|
1,
|
|
90
|
-
undefined
|
|
95
|
+
undefined,
|
|
96
|
+
mockLogger
|
|
91
97
|
);
|
|
92
98
|
options[1].onCheck(false);
|
|
93
99
|
expect(mockChange).toHaveBeenLastCalledWith([
|
|
94
100
|
{ name: 'O2', value: false },
|
|
95
101
|
]);
|
|
96
102
|
});
|
|
103
|
+
it('should not filter response (checkboxGroup) when its conditionFilter evaluation fails', () => {
|
|
104
|
+
const definition = {
|
|
105
|
+
...checkboxGroupDefinition,
|
|
106
|
+
responses: [
|
|
107
|
+
{
|
|
108
|
+
label: 'Option 1',
|
|
109
|
+
response: { name: 'O1' },
|
|
110
|
+
id: 'id1',
|
|
111
|
+
conditionFilter: { type: 'VTL', value: 'invalid expression' },
|
|
112
|
+
},
|
|
113
|
+
],
|
|
114
|
+
} satisfies DeepTranslateExpression<LunaticComponentDefinition>;
|
|
115
|
+
|
|
116
|
+
// mock variables.run for having an error interpreting a variable
|
|
117
|
+
vi.spyOn(variables, 'run').mockImplementation(() => {
|
|
118
|
+
throw new Error('Test error');
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
const options = getOptionsProp(
|
|
122
|
+
definition,
|
|
123
|
+
variables,
|
|
124
|
+
mockChange,
|
|
125
|
+
undefined,
|
|
126
|
+
undefined,
|
|
127
|
+
mockLogger
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
// Ensure the option is not filtered
|
|
131
|
+
expect(options).toHaveLength(1);
|
|
132
|
+
});
|
|
133
|
+
it('should not filter option (radio) when its conditionFilter evaluation fails', () => {
|
|
134
|
+
const definition = {
|
|
135
|
+
id: 'RadioGroup',
|
|
136
|
+
componentType: 'Radio',
|
|
137
|
+
options: [
|
|
138
|
+
{
|
|
139
|
+
label: 'Option 1',
|
|
140
|
+
value: 'id1',
|
|
141
|
+
conditionFilter: { type: 'VTL', value: 'invalid expression' },
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
} as any as DeepTranslateExpression<LunaticComponentDefinition>;
|
|
145
|
+
|
|
146
|
+
// Mock `variables.run` to throw an error
|
|
147
|
+
vi.spyOn(variables, 'run').mockImplementation(() => {
|
|
148
|
+
throw new Error('Test error');
|
|
149
|
+
});
|
|
150
|
+
|
|
151
|
+
const options = getOptionsProp(
|
|
152
|
+
definition,
|
|
153
|
+
variables,
|
|
154
|
+
mockChange,
|
|
155
|
+
undefined,
|
|
156
|
+
undefined,
|
|
157
|
+
mockLogger
|
|
158
|
+
);
|
|
159
|
+
|
|
160
|
+
// Ensure the option is not filtered
|
|
161
|
+
expect(options).toHaveLength(1);
|
|
162
|
+
});
|
|
97
163
|
});
|
|
98
164
|
});
|
|
@@ -7,6 +7,7 @@ import type { ReactNode } from 'react';
|
|
|
7
7
|
import type { DeepTranslateExpression } from '../commons/fill-components/fill-component-expressions';
|
|
8
8
|
import { isNumber } from '../../utils/number';
|
|
9
9
|
import type { LunaticVariablesStore } from '../commons/variables/lunatic-variables-store';
|
|
10
|
+
import { LunaticLogger } from '../logger/type';
|
|
10
11
|
|
|
11
12
|
/* Used for radio option and checkbox one option */
|
|
12
13
|
export type InterpretedOption = {
|
|
@@ -29,7 +30,8 @@ export function getOptionsProp(
|
|
|
29
30
|
variables: LunaticVariablesStore,
|
|
30
31
|
handleChanges: LunaticChangesHandler,
|
|
31
32
|
pagerIteration: LunaticState['pager']['iteration'],
|
|
32
|
-
value: unknown
|
|
33
|
+
value: unknown,
|
|
34
|
+
logger: LunaticLogger
|
|
33
35
|
) {
|
|
34
36
|
const iteration = isNumber(pagerIteration) ? [pagerIteration] : undefined;
|
|
35
37
|
//const iteration = pagerIteration ? [pagerIteration] : undefined;
|
|
@@ -40,7 +42,16 @@ export function getOptionsProp(
|
|
|
40
42
|
if (!response.conditionFilter) {
|
|
41
43
|
return true;
|
|
42
44
|
}
|
|
43
|
-
|
|
45
|
+
try {
|
|
46
|
+
return variables.run(response.conditionFilter.value, { iteration });
|
|
47
|
+
} catch (e) {
|
|
48
|
+
// If there is an error interpreting a variable, we do not filter
|
|
49
|
+
logger({
|
|
50
|
+
type: 'ERROR',
|
|
51
|
+
error: e as Error,
|
|
52
|
+
});
|
|
53
|
+
return true;
|
|
54
|
+
}
|
|
44
55
|
})
|
|
45
56
|
.map((response) => ({
|
|
46
57
|
label: response.label,
|
|
@@ -74,7 +85,16 @@ export function getOptionsProp(
|
|
|
74
85
|
if (!('conditionFilter' in option) || !option.conditionFilter) {
|
|
75
86
|
return true;
|
|
76
87
|
}
|
|
77
|
-
|
|
88
|
+
try {
|
|
89
|
+
return variables.run(option.conditionFilter.value, { iteration });
|
|
90
|
+
} catch (e) {
|
|
91
|
+
// If there is an error interpreting a variable, we do not filter
|
|
92
|
+
logger({
|
|
93
|
+
type: 'ERROR',
|
|
94
|
+
error: e as Error,
|
|
95
|
+
});
|
|
96
|
+
return true;
|
|
97
|
+
}
|
|
78
98
|
})
|
|
79
99
|
.map((option) => ({
|
|
80
100
|
label: option.label,
|