@inseefr/lunatic 3.5.0-rc.0 → 3.5.0-rc.1
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/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 +1 -0
- 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/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 +1 -0
- 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/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/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 +164 -8
- 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 +1 -0
- 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 +0 -4
- package/esm/use-lunatic/use-lunatic.d.ts +1 -2
- 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/main.css +20 -0
- package/main.css.map +1 -1
- package/package.json +61 -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/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 +1 -0
- package/src/css/components/Input.scss +10 -0
- package/src/css/components/Roundabout.scss +10 -0
- 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 +9 -1
- package/src/stories/behaviour/performance/source.json +4 -20
- package/src/stories/behaviour/performance/srcv.json +44747 -0
- 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/page.ts +10 -0
- package/src/use-lunatic/commons/variables/behaviours/cleaning-behaviour.ts +182 -24
- package/src/use-lunatic/commons/variables/get-questionnaire-data.ts +0 -12
- package/src/use-lunatic/commons/variables/lunatic-variables-store.spec.ts +190 -8
- 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/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 +0 -4
- package/src/use-lunatic/use-lunatic.test.ts +2 -21
- package/src/use-lunatic/use-lunatic.ts +5 -4
- 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/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/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 +187 -8
- 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 +1 -0
- 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 +0 -4
- package/use-lunatic/use-lunatic.d.ts +1 -2
- 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/hooks/useArticulation.d.ts +0 -58
- package/esm/hooks/useArticulation.js +0 -81
- package/esm/hooks/useArticulation.js.map +0 -1
- package/hooks/useArticulation.d.ts +0 -58
- package/hooks/useArticulation.js +0 -81
- package/hooks/useArticulation.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/hooks/useArticulation.ts +0 -124
- package/src/stories/behaviour/articulation/articulation.stories.tsx +0 -105
- package/src/stories/behaviour/articulation/roundabout.json +0 -348
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export declare const EVENT_FOCUS_IN = "focus-in";
|
|
2
|
-
export declare const EVENT_FOCUS_OUT = "focus-out";
|
|
3
|
-
export declare const EVENT_SELECTION = "selection";
|
|
4
|
-
export declare const EVENT_CLICK = "click";
|
|
5
|
-
export declare const EVENT_VALUE_CHANGE = "value-changed";
|
|
6
|
-
export declare const INPUT_CATEGORY = "lunatic-input";
|
|
7
|
-
export declare const BUTTON_CATEGORY = "lunatic-button";
|
|
8
|
-
export declare const LINK_CATEGORY = "lunatic-link";
|
|
9
|
-
export declare const TOOLTIP_CATEGORY = "lunatic-tooltip";
|
|
10
|
-
export declare const CALCULATED_VAR_CATEGORY = "lunatic-calculated-var";
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// Event types for paradata
|
|
2
|
-
export const EVENT_FOCUS_IN = 'focus-in';
|
|
3
|
-
export const EVENT_FOCUS_OUT = 'focus-out';
|
|
4
|
-
export const EVENT_SELECTION = 'selection';
|
|
5
|
-
export const EVENT_CLICK = 'click';
|
|
6
|
-
export const EVENT_VALUE_CHANGE = 'value-changed';
|
|
7
|
-
// Category of object
|
|
8
|
-
export const INPUT_CATEGORY = 'lunatic-input';
|
|
9
|
-
export const BUTTON_CATEGORY = 'lunatic-button';
|
|
10
|
-
export const LINK_CATEGORY = 'lunatic-link';
|
|
11
|
-
export const TOOLTIP_CATEGORY = 'lunatic-tooltip';
|
|
12
|
-
export const CALCULATED_VAR_CATEGORY = 'lunatic-calculated-var';
|
|
13
|
-
//# sourceMappingURL=event-types.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"event-types.js","sourceRoot":"","sources":["../../src/constants/event-types.ts"],"names":[],"mappings":"AAAA,2BAA2B;AAC3B,MAAM,CAAC,MAAM,cAAc,GAAG,UAAU,CAAC;AACzC,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC;AAC3C,MAAM,CAAC,MAAM,eAAe,GAAG,WAAW,CAAC;AAC3C,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAC;AACnC,MAAM,CAAC,MAAM,kBAAkB,GAAG,eAAe,CAAC;AAElD,qBAAqB;AACrB,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC;AAC9C,MAAM,CAAC,MAAM,eAAe,GAAG,gBAAgB,CAAC;AAChD,MAAM,CAAC,MAAM,aAAa,GAAG,cAAc,CAAC;AAC5C,MAAM,CAAC,MAAM,gBAAgB,GAAG,iBAAiB,CAAC;AAClD,MAAM,CAAC,MAAM,uBAAuB,GAAG,wBAAwB,CAAC"}
|
package/esm/constants/index.d.ts
DELETED
package/esm/constants/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/constants/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAC;AAClC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,eAAe,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,eAAe,CAAC"}
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
export declare const STORE_DATA_NAME = "store/entities";
|
|
2
|
-
export declare const STORE_INFO_NAME = "store/info";
|
|
3
|
-
export declare const STORE_INDEX_NAME = "store/entities/index";
|
|
4
|
-
export declare const STORE_INDEX_PATH = "searching";
|
|
5
|
-
export declare const MAX_STRING: string;
|
|
6
|
-
export declare const SEARCH_TYPES: {
|
|
7
|
-
prefix: string;
|
|
8
|
-
tokens: string;
|
|
9
|
-
};
|
|
10
|
-
declare const IndexedDBStore: {
|
|
11
|
-
STORE_DATA_NAME: string;
|
|
12
|
-
STORE_INDEX_NAME: string;
|
|
13
|
-
STORE_INDEX_PATH: string;
|
|
14
|
-
MAX_STRING: string;
|
|
15
|
-
SEARCH_TYPES: {
|
|
16
|
-
prefix: string;
|
|
17
|
-
tokens: string;
|
|
18
|
-
};
|
|
19
|
-
STORE_INFO_NAME: string;
|
|
20
|
-
};
|
|
21
|
-
export default IndexedDBStore;
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
export const STORE_DATA_NAME = 'store/entities';
|
|
2
|
-
export const STORE_INFO_NAME = 'store/info';
|
|
3
|
-
export const STORE_INDEX_NAME = 'store/entities/index';
|
|
4
|
-
export const STORE_INDEX_PATH = 'searching';
|
|
5
|
-
export const MAX_STRING = String.fromCharCode(65535);
|
|
6
|
-
export const SEARCH_TYPES = {
|
|
7
|
-
prefix: 'search/prefix',
|
|
8
|
-
tokens: 'search/tokens',
|
|
9
|
-
};
|
|
10
|
-
const IndexedDBStore = {
|
|
11
|
-
STORE_DATA_NAME,
|
|
12
|
-
STORE_INDEX_NAME,
|
|
13
|
-
STORE_INDEX_PATH,
|
|
14
|
-
MAX_STRING,
|
|
15
|
-
SEARCH_TYPES,
|
|
16
|
-
STORE_INFO_NAME,
|
|
17
|
-
};
|
|
18
|
-
export default IndexedDBStore;
|
|
19
|
-
//# sourceMappingURL=indexedDBStore.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"indexedDBStore.js","sourceRoot":"","sources":["../../src/constants/indexedDBStore.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,eAAe,GAAG,gBAAgB,CAAC;AAChD,MAAM,CAAC,MAAM,eAAe,GAAG,YAAY,CAAC;AAC5C,MAAM,CAAC,MAAM,gBAAgB,GAAG,sBAAsB,CAAC;AACvD,MAAM,CAAC,MAAM,gBAAgB,GAAG,WAAW,CAAC;AAC5C,MAAM,CAAC,MAAM,UAAU,GAAG,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;AACrD,MAAM,CAAC,MAAM,YAAY,GAAG;IAC3B,MAAM,EAAE,eAAe;IACvB,MAAM,EAAE,eAAe;CACvB,CAAC;AAEF,MAAM,cAAc,GAAG;IACtB,eAAe;IACf,gBAAgB;IAChB,gBAAgB;IAChB,UAAU;IACV,YAAY;IACZ,eAAe;CACf,CAAC;AAEF,eAAe,cAAc,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const supportedPreferences: string[];
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"supported-preferences.js","sourceRoot":"","sources":["../../src/constants/supported-preferences.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,CAAC,MAAM,eAAe,CAAC;AAEnC,gBAAgB;AAChB,MAAM,CAAC,MAAM,oBAAoB,GAAG;IACnC,CAAC,CAAC,QAAQ;IACV,CAAC,CAAC,SAAS;IACX,CAAC,CAAC,MAAM;IACR,CAAC,CAAC,MAAM;IACR,CAAC,CAAC,QAAQ;CACV,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"value-types.js","sourceRoot":"","sources":["../../src/constants/value-types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC;AACnC,MAAM,CAAC,MAAM,SAAS,GAAG,WAAW,CAAC;AACrC,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC;AAC/B,MAAM,CAAC,MAAM,MAAM,GAAG,QAAQ,CAAC;AAC/B,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAU,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"variable-types.js","sourceRoot":"","sources":["../../src/constants/variable-types.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,QAAQ,GAAG,UAAmB,CAAC;AAC5C,MAAM,CAAC,MAAM,UAAU,GAAG,YAAqB,CAAC;AAChD,gCAAgC;AAChC,uCAAuC"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { LunaticSource } from '../type.source';
|
|
2
|
-
import type { LunaticData } from '../use-lunatic/type';
|
|
3
|
-
import { type ReactNode } from 'react';
|
|
4
|
-
type ArticulationItem = {
|
|
5
|
-
label: string;
|
|
6
|
-
value: string;
|
|
7
|
-
};
|
|
8
|
-
type Articulation = {
|
|
9
|
-
source: string;
|
|
10
|
-
items: ArticulationItem[];
|
|
11
|
-
};
|
|
12
|
-
type Item = {
|
|
13
|
-
cells: {
|
|
14
|
-
label: string;
|
|
15
|
-
value: ReactNode;
|
|
16
|
-
page?: string;
|
|
17
|
-
}[];
|
|
18
|
-
progress: number;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Hook to get articulation state
|
|
22
|
-
*
|
|
23
|
-
* ## Why this hook
|
|
24
|
-
*
|
|
25
|
-
* The goal of this hook is to provide insights about a roundabout using extra information inserted in the JSON source
|
|
26
|
-
* provided to Lunatic.
|
|
27
|
-
*
|
|
28
|
-
* For instance
|
|
29
|
-
*
|
|
30
|
-
* ```
|
|
31
|
-
* "articulation": {
|
|
32
|
-
* "source": "roundabout",
|
|
33
|
-
* "items": [
|
|
34
|
-
* {
|
|
35
|
-
* "label": "Prénom",
|
|
36
|
-
* "value": "PRENOMS"
|
|
37
|
-
* },
|
|
38
|
-
* {
|
|
39
|
-
* "label": "Sexe",
|
|
40
|
-
* "value": "if SEXE = \"H\" then \"Homme\" else \"Femme\""
|
|
41
|
-
* },
|
|
42
|
-
* {
|
|
43
|
-
* "label": "Age",
|
|
44
|
-
* "value": "cast(AGE, string) || \" ans\""
|
|
45
|
-
* }
|
|
46
|
-
* ]
|
|
47
|
-
* },
|
|
48
|
-
* ```
|
|
49
|
-
*
|
|
50
|
-
* - source is the ID of the roundabout component
|
|
51
|
-
* - items define the field to extract from the roundabout data
|
|
52
|
-
*/
|
|
53
|
-
export declare function useArticulation(source: LunaticSource & {
|
|
54
|
-
articulation: Articulation;
|
|
55
|
-
}, data: LunaticData): {
|
|
56
|
-
items: Item[];
|
|
57
|
-
};
|
|
58
|
-
export {};
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
import { reducerInitializer } from '../use-lunatic/reducer/reducerInitializer';
|
|
2
|
-
import { useMemo } from 'react';
|
|
3
|
-
import { times } from '../utils/array';
|
|
4
|
-
import { forceInt } from '../utils/number';
|
|
5
|
-
/**
|
|
6
|
-
* Hook to get articulation state
|
|
7
|
-
*
|
|
8
|
-
* ## Why this hook
|
|
9
|
-
*
|
|
10
|
-
* The goal of this hook is to provide insights about a roundabout using extra information inserted in the JSON source
|
|
11
|
-
* provided to Lunatic.
|
|
12
|
-
*
|
|
13
|
-
* For instance
|
|
14
|
-
*
|
|
15
|
-
* ```
|
|
16
|
-
* "articulation": {
|
|
17
|
-
* "source": "roundabout",
|
|
18
|
-
* "items": [
|
|
19
|
-
* {
|
|
20
|
-
* "label": "Prénom",
|
|
21
|
-
* "value": "PRENOMS"
|
|
22
|
-
* },
|
|
23
|
-
* {
|
|
24
|
-
* "label": "Sexe",
|
|
25
|
-
* "value": "if SEXE = \"H\" then \"Homme\" else \"Femme\""
|
|
26
|
-
* },
|
|
27
|
-
* {
|
|
28
|
-
* "label": "Age",
|
|
29
|
-
* "value": "cast(AGE, string) || \" ans\""
|
|
30
|
-
* }
|
|
31
|
-
* ]
|
|
32
|
-
* },
|
|
33
|
-
* ```
|
|
34
|
-
*
|
|
35
|
-
* - source is the ID of the roundabout component
|
|
36
|
-
* - items define the field to extract from the roundabout data
|
|
37
|
-
*/
|
|
38
|
-
export function useArticulation(source, data) {
|
|
39
|
-
const roundabout = useMemo(() => findComponentById(source.components, source.articulation.source), [source]);
|
|
40
|
-
const { variables } = useMemo(() => reducerInitializer({ source, data }), [source, data]);
|
|
41
|
-
const iterations = useMemo(() => { var _a; return forceInt(variables.run((_a = roundabout === null || roundabout === void 0 ? void 0 : roundabout.iterations.value) !== null && _a !== void 0 ? _a : '0')); },
|
|
42
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
43
|
-
[source, data]);
|
|
44
|
-
const rows = useMemo(() => {
|
|
45
|
-
return times(iterations, (k) => source.articulation.items.map((item) => ({
|
|
46
|
-
label: item.label,
|
|
47
|
-
value: variables.run(item.value, { iteration: [k] }),
|
|
48
|
-
})));
|
|
49
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
50
|
-
}, [source, data, iterations, roundabout === null || roundabout === void 0 ? void 0 : roundabout.progressVariable]);
|
|
51
|
-
if (!roundabout) {
|
|
52
|
-
return {
|
|
53
|
-
items: [],
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
return {
|
|
57
|
-
items: rows.map((row, k) => {
|
|
58
|
-
var _a;
|
|
59
|
-
return ({
|
|
60
|
-
cells: row,
|
|
61
|
-
progress: forceInt((_a = variables.get(roundabout.progressVariable, [k])) !== null && _a !== void 0 ? _a : -1),
|
|
62
|
-
page: roundabout.page ? `${roundabout.page}.1#${k + 1}` : '1',
|
|
63
|
-
});
|
|
64
|
-
}),
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
function findComponentById(components, id) {
|
|
68
|
-
for (const c of components) {
|
|
69
|
-
if ('id' in c && c.id === id && c.componentType === 'Roundabout') {
|
|
70
|
-
return c;
|
|
71
|
-
}
|
|
72
|
-
if ('components' in c) {
|
|
73
|
-
const child = findComponentById(c.components, id);
|
|
74
|
-
if (child) {
|
|
75
|
-
return child;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
//# sourceMappingURL=useArticulation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useArticulation.js","sourceRoot":"","sources":["../../src/hooks/useArticulation.ts"],"names":[],"mappings":"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"}
|
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
import type { LunaticSource } from '../type.source';
|
|
2
|
-
import type { LunaticData } from '../use-lunatic/type';
|
|
3
|
-
import { type ReactNode } from 'react';
|
|
4
|
-
type ArticulationItem = {
|
|
5
|
-
label: string;
|
|
6
|
-
value: string;
|
|
7
|
-
};
|
|
8
|
-
type Articulation = {
|
|
9
|
-
source: string;
|
|
10
|
-
items: ArticulationItem[];
|
|
11
|
-
};
|
|
12
|
-
type Item = {
|
|
13
|
-
cells: {
|
|
14
|
-
label: string;
|
|
15
|
-
value: ReactNode;
|
|
16
|
-
page?: string;
|
|
17
|
-
}[];
|
|
18
|
-
progress: number;
|
|
19
|
-
};
|
|
20
|
-
/**
|
|
21
|
-
* Hook to get articulation state
|
|
22
|
-
*
|
|
23
|
-
* ## Why this hook
|
|
24
|
-
*
|
|
25
|
-
* The goal of this hook is to provide insights about a roundabout using extra information inserted in the JSON source
|
|
26
|
-
* provided to Lunatic.
|
|
27
|
-
*
|
|
28
|
-
* For instance
|
|
29
|
-
*
|
|
30
|
-
* ```
|
|
31
|
-
* "articulation": {
|
|
32
|
-
* "source": "roundabout",
|
|
33
|
-
* "items": [
|
|
34
|
-
* {
|
|
35
|
-
* "label": "Prénom",
|
|
36
|
-
* "value": "PRENOMS"
|
|
37
|
-
* },
|
|
38
|
-
* {
|
|
39
|
-
* "label": "Sexe",
|
|
40
|
-
* "value": "if SEXE = \"H\" then \"Homme\" else \"Femme\""
|
|
41
|
-
* },
|
|
42
|
-
* {
|
|
43
|
-
* "label": "Age",
|
|
44
|
-
* "value": "cast(AGE, string) || \" ans\""
|
|
45
|
-
* }
|
|
46
|
-
* ]
|
|
47
|
-
* },
|
|
48
|
-
* ```
|
|
49
|
-
*
|
|
50
|
-
* - source is the ID of the roundabout component
|
|
51
|
-
* - items define the field to extract from the roundabout data
|
|
52
|
-
*/
|
|
53
|
-
export declare function useArticulation(source: LunaticSource & {
|
|
54
|
-
articulation: Articulation;
|
|
55
|
-
}, data: LunaticData): {
|
|
56
|
-
items: Item[];
|
|
57
|
-
};
|
|
58
|
-
export {};
|
package/hooks/useArticulation.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useArticulation = useArticulation;
|
|
4
|
-
const reducerInitializer_1 = require("../use-lunatic/reducer/reducerInitializer");
|
|
5
|
-
const react_1 = require("react");
|
|
6
|
-
const array_1 = require("../utils/array");
|
|
7
|
-
const number_1 = require("../utils/number");
|
|
8
|
-
/**
|
|
9
|
-
* Hook to get articulation state
|
|
10
|
-
*
|
|
11
|
-
* ## Why this hook
|
|
12
|
-
*
|
|
13
|
-
* The goal of this hook is to provide insights about a roundabout using extra information inserted in the JSON source
|
|
14
|
-
* provided to Lunatic.
|
|
15
|
-
*
|
|
16
|
-
* For instance
|
|
17
|
-
*
|
|
18
|
-
* ```
|
|
19
|
-
* "articulation": {
|
|
20
|
-
* "source": "roundabout",
|
|
21
|
-
* "items": [
|
|
22
|
-
* {
|
|
23
|
-
* "label": "Prénom",
|
|
24
|
-
* "value": "PRENOMS"
|
|
25
|
-
* },
|
|
26
|
-
* {
|
|
27
|
-
* "label": "Sexe",
|
|
28
|
-
* "value": "if SEXE = \"H\" then \"Homme\" else \"Femme\""
|
|
29
|
-
* },
|
|
30
|
-
* {
|
|
31
|
-
* "label": "Age",
|
|
32
|
-
* "value": "cast(AGE, string) || \" ans\""
|
|
33
|
-
* }
|
|
34
|
-
* ]
|
|
35
|
-
* },
|
|
36
|
-
* ```
|
|
37
|
-
*
|
|
38
|
-
* - source is the ID of the roundabout component
|
|
39
|
-
* - items define the field to extract from the roundabout data
|
|
40
|
-
*/
|
|
41
|
-
function useArticulation(source, data) {
|
|
42
|
-
const roundabout = (0, react_1.useMemo)(() => findComponentById(source.components, source.articulation.source), [source]);
|
|
43
|
-
const { variables } = (0, react_1.useMemo)(() => (0, reducerInitializer_1.reducerInitializer)({ source, data }), [source, data]);
|
|
44
|
-
const iterations = (0, react_1.useMemo)(() => (0, number_1.forceInt)(variables.run(roundabout?.iterations.value ?? '0')),
|
|
45
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
46
|
-
[source, data]);
|
|
47
|
-
const rows = (0, react_1.useMemo)(() => {
|
|
48
|
-
return (0, array_1.times)(iterations, (k) => source.articulation.items.map((item) => ({
|
|
49
|
-
label: item.label,
|
|
50
|
-
value: variables.run(item.value, { iteration: [k] }),
|
|
51
|
-
})));
|
|
52
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
53
|
-
}, [source, data, iterations, roundabout?.progressVariable]);
|
|
54
|
-
if (!roundabout) {
|
|
55
|
-
return {
|
|
56
|
-
items: [],
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
items: rows.map((row, k) => ({
|
|
61
|
-
cells: row,
|
|
62
|
-
progress: (0, number_1.forceInt)(variables.get(roundabout.progressVariable, [k]) ?? -1),
|
|
63
|
-
page: roundabout.page ? `${roundabout.page}.1#${k + 1}` : '1',
|
|
64
|
-
})),
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
function findComponentById(components, id) {
|
|
68
|
-
for (const c of components) {
|
|
69
|
-
if ('id' in c && c.id === id && c.componentType === 'Roundabout') {
|
|
70
|
-
return c;
|
|
71
|
-
}
|
|
72
|
-
if ('components' in c) {
|
|
73
|
-
const child = findComponentById(c.components, id);
|
|
74
|
-
if (child) {
|
|
75
|
-
return child;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
return null;
|
|
80
|
-
}
|
|
81
|
-
//# sourceMappingURL=useArticulation.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"useArticulation.js","sourceRoot":"","sources":["../src/hooks/useArticulation.ts"],"names":[],"mappings":";;AA+DA,0CA0CC;AAnGD,kFAA+E;AAC/E,iCAAgD;AAChD,0CAAuC;AACvC,4CAA2C;AAqB3C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAgCG;AACH,SAAgB,eAAe,CAC9B,MAAsD,EACtD,IAAiB;IAEjB,MAAM,UAAU,GAAG,IAAA,eAAO,EACzB,GAAG,EAAE,CAAC,iBAAiB,CAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,EACtE,CAAC,MAAM,CAAC,CACR,CAAC;IACF,MAAM,EAAE,SAAS,EAAE,GAAG,IAAA,eAAO,EAC5B,GAAG,EAAE,CAAC,IAAA,uCAAkB,EAAC,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC,EAC1C,CAAC,MAAM,EAAE,IAAI,CAAC,CACd,CAAC;IAEF,MAAM,UAAU,GAAG,IAAA,eAAO,EACzB,GAAG,EAAE,CAAC,IAAA,iBAAQ,EAAC,SAAS,CAAC,GAAG,CAAC,UAAU,EAAE,UAAU,CAAC,KAAK,IAAI,GAAG,CAAC,CAAC;IAClE,uDAAuD;IACvD,CAAC,MAAM,EAAE,IAAI,CAAC,CACd,CAAC;IAEF,MAAM,IAAI,GAAG,IAAA,eAAO,EAAC,GAAG,EAAE;QACzB,OAAO,IAAA,aAAK,EAAC,UAAU,EAAE,CAAC,CAAC,EAAE,EAAE,CAC9B,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC;YACxC,KAAK,EAAE,IAAI,CAAC,KAAK;YACjB,KAAK,EAAE,SAAS,CAAC,GAAG,CAAC,IAAI,CAAC,KAAK,EAAE,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAc;SACjE,CAAC,CAAC,CACH,CAAC;QACF,uDAAuD;IACxD,CAAC,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,UAAU,EAAE,UAAU,EAAE,gBAAgB,CAAC,CAAC,CAAC;IAE7D,IAAI,CAAC,UAAU,EAAE,CAAC;QACjB,OAAO;YACN,KAAK,EAAE,EAAE;SACT,CAAC;IACH,CAAC;IAED,OAAO;QACN,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,GAAG,EAAE,CAAC,EAAE,EAAE,CAAC,CAAC;YAC5B,KAAK,EAAE,GAAG;YACV,QAAQ,EAAE,IAAA,iBAAQ,EAAC,SAAS,CAAC,GAAG,CAAC,UAAU,CAAC,gBAAgB,EAAE,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC;YACzE,IAAI,EAAE,UAAU,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,UAAU,CAAC,IAAI,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG;SAC7D,CAAC,CAAC;KACH,CAAC;AACH,CAAC;AAED,SAAS,iBAAiB,CACzB,UAAiC,EACjC,EAAU;IAEV,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;QAC5B,IAAI,IAAI,IAAI,CAAC,IAAI,CAAC,CAAC,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,aAAa,KAAK,YAAY,EAAE,CAAC;YAClE,OAAO,CAAC,CAAC;QACV,CAAC;QACD,IAAI,YAAY,IAAI,CAAC,EAAE,CAAC;YACvB,MAAM,KAAK,GAAG,iBAAiB,CAAC,CAAC,CAAC,UAAU,EAAE,EAAE,CAAC,CAAC;YAClD,IAAI,KAAK,EAAE,CAAC;gBACX,OAAO,KAAK,CAAC;YACd,CAAC;QACF,CAAC;IACF,CAAC;IACD,OAAO,IAAI,CAAC;AACb,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const CHECKBOX_GROUP = 'CheckboxGroup';
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
// Declaration position
|
|
2
|
-
|
|
3
|
-
export const BEFORE_QUESTION_TEXT = 'BEFORE_QUESTION_TEXT';
|
|
4
|
-
export const AFTER_QUESTION_TEXT = 'AFTER_QUESTION_TEXT';
|
|
5
|
-
export const DETACHABLE = 'DETACHABLE';
|
|
6
|
-
|
|
7
|
-
// Declaration types
|
|
8
|
-
|
|
9
|
-
export const INSTRUCTION = 'INSTRUCTION';
|
|
10
|
-
export const COMMENT = 'COMMENT';
|
|
11
|
-
export const HELP = 'HELP';
|
|
12
|
-
export const WARNING = 'WARNING';
|
|
13
|
-
export const MESSAGE_FILTER = 'MESSAGE_FILTER';
|
|
14
|
-
export const STATEMENT = 'STATEMENT';
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
// Event types for paradata
|
|
2
|
-
export const EVENT_FOCUS_IN = 'focus-in';
|
|
3
|
-
export const EVENT_FOCUS_OUT = 'focus-out';
|
|
4
|
-
export const EVENT_SELECTION = 'selection';
|
|
5
|
-
export const EVENT_CLICK = 'click';
|
|
6
|
-
export const EVENT_VALUE_CHANGE = 'value-changed';
|
|
7
|
-
|
|
8
|
-
// Category of object
|
|
9
|
-
export const INPUT_CATEGORY = 'lunatic-input';
|
|
10
|
-
export const BUTTON_CATEGORY = 'lunatic-button';
|
|
11
|
-
export const LINK_CATEGORY = 'lunatic-link';
|
|
12
|
-
export const TOOLTIP_CATEGORY = 'lunatic-tooltip';
|
|
13
|
-
export const CALCULATED_VAR_CATEGORY = 'lunatic-calculated-var';
|
package/src/constants/index.ts
DELETED
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
export const STORE_DATA_NAME = 'store/entities';
|
|
2
|
-
export const STORE_INFO_NAME = 'store/info';
|
|
3
|
-
export const STORE_INDEX_NAME = 'store/entities/index';
|
|
4
|
-
export const STORE_INDEX_PATH = 'searching';
|
|
5
|
-
export const MAX_STRING = String.fromCharCode(65535);
|
|
6
|
-
export const SEARCH_TYPES = {
|
|
7
|
-
prefix: 'search/prefix',
|
|
8
|
-
tokens: 'search/tokens',
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
const IndexedDBStore = {
|
|
12
|
-
STORE_DATA_NAME,
|
|
13
|
-
STORE_INDEX_NAME,
|
|
14
|
-
STORE_INDEX_PATH,
|
|
15
|
-
MAX_STRING,
|
|
16
|
-
SEARCH_TYPES,
|
|
17
|
-
STORE_INFO_NAME,
|
|
18
|
-
};
|
|
19
|
-
|
|
20
|
-
export default IndexedDBStore;
|
|
@@ -1,124 +0,0 @@
|
|
|
1
|
-
import type {
|
|
2
|
-
ComponentDefinition,
|
|
3
|
-
ComponentRoundaboutDefinition,
|
|
4
|
-
LunaticSource,
|
|
5
|
-
} from '../type.source';
|
|
6
|
-
import type { LunaticData } from '../use-lunatic/type';
|
|
7
|
-
import { reducerInitializer } from '../use-lunatic/reducer/reducerInitializer';
|
|
8
|
-
import { type ReactNode, useMemo } from 'react';
|
|
9
|
-
import { times } from '../utils/array';
|
|
10
|
-
import { forceInt } from '../utils/number';
|
|
11
|
-
|
|
12
|
-
type ArticulationItem = {
|
|
13
|
-
label: string;
|
|
14
|
-
value: string;
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
type Articulation = {
|
|
18
|
-
source: string;
|
|
19
|
-
items: ArticulationItem[];
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
type Item = {
|
|
23
|
-
cells: {
|
|
24
|
-
label: string;
|
|
25
|
-
value: ReactNode;
|
|
26
|
-
page?: string;
|
|
27
|
-
}[];
|
|
28
|
-
progress: number; // -1: not completed, 0: started, 1: finished
|
|
29
|
-
};
|
|
30
|
-
|
|
31
|
-
/**
|
|
32
|
-
* Hook to get articulation state
|
|
33
|
-
*
|
|
34
|
-
* ## Why this hook
|
|
35
|
-
*
|
|
36
|
-
* The goal of this hook is to provide insights about a roundabout using extra information inserted in the JSON source
|
|
37
|
-
* provided to Lunatic.
|
|
38
|
-
*
|
|
39
|
-
* For instance
|
|
40
|
-
*
|
|
41
|
-
* ```
|
|
42
|
-
* "articulation": {
|
|
43
|
-
* "source": "roundabout",
|
|
44
|
-
* "items": [
|
|
45
|
-
* {
|
|
46
|
-
* "label": "Prénom",
|
|
47
|
-
* "value": "PRENOMS"
|
|
48
|
-
* },
|
|
49
|
-
* {
|
|
50
|
-
* "label": "Sexe",
|
|
51
|
-
* "value": "if SEXE = \"H\" then \"Homme\" else \"Femme\""
|
|
52
|
-
* },
|
|
53
|
-
* {
|
|
54
|
-
* "label": "Age",
|
|
55
|
-
* "value": "cast(AGE, string) || \" ans\""
|
|
56
|
-
* }
|
|
57
|
-
* ]
|
|
58
|
-
* },
|
|
59
|
-
* ```
|
|
60
|
-
*
|
|
61
|
-
* - source is the ID of the roundabout component
|
|
62
|
-
* - items define the field to extract from the roundabout data
|
|
63
|
-
*/
|
|
64
|
-
export function useArticulation(
|
|
65
|
-
source: LunaticSource & { articulation: Articulation },
|
|
66
|
-
data: LunaticData
|
|
67
|
-
): { items: Item[] } {
|
|
68
|
-
const roundabout = useMemo(
|
|
69
|
-
() => findComponentById(source.components, source.articulation.source),
|
|
70
|
-
[source]
|
|
71
|
-
);
|
|
72
|
-
const { variables } = useMemo(
|
|
73
|
-
() => reducerInitializer({ source, data }),
|
|
74
|
-
[source, data]
|
|
75
|
-
);
|
|
76
|
-
|
|
77
|
-
const iterations = useMemo(
|
|
78
|
-
() => forceInt(variables.run(roundabout?.iterations.value ?? '0')),
|
|
79
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
80
|
-
[source, data]
|
|
81
|
-
);
|
|
82
|
-
|
|
83
|
-
const rows = useMemo(() => {
|
|
84
|
-
return times(iterations, (k) =>
|
|
85
|
-
source.articulation.items.map((item) => ({
|
|
86
|
-
label: item.label,
|
|
87
|
-
value: variables.run(item.value, { iteration: [k] }) as ReactNode,
|
|
88
|
-
}))
|
|
89
|
-
);
|
|
90
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
91
|
-
}, [source, data, iterations, roundabout?.progressVariable]);
|
|
92
|
-
|
|
93
|
-
if (!roundabout) {
|
|
94
|
-
return {
|
|
95
|
-
items: [],
|
|
96
|
-
};
|
|
97
|
-
}
|
|
98
|
-
|
|
99
|
-
return {
|
|
100
|
-
items: rows.map((row, k) => ({
|
|
101
|
-
cells: row,
|
|
102
|
-
progress: forceInt(variables.get(roundabout.progressVariable, [k]) ?? -1),
|
|
103
|
-
page: roundabout.page ? `${roundabout.page}.1#${k + 1}` : '1',
|
|
104
|
-
})),
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function findComponentById(
|
|
109
|
-
components: ComponentDefinition[],
|
|
110
|
-
id: string
|
|
111
|
-
): (ComponentRoundaboutDefinition & { page?: string }) | null {
|
|
112
|
-
for (const c of components) {
|
|
113
|
-
if ('id' in c && c.id === id && c.componentType === 'Roundabout') {
|
|
114
|
-
return c;
|
|
115
|
-
}
|
|
116
|
-
if ('components' in c) {
|
|
117
|
-
const child = findComponentById(c.components, id);
|
|
118
|
-
if (child) {
|
|
119
|
-
return child;
|
|
120
|
-
}
|
|
121
|
-
}
|
|
122
|
-
}
|
|
123
|
-
return null;
|
|
124
|
-
}
|