@inseefr/lunatic 0.1.0-hackathon → 0.1.0-v2
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/lib/index.js +1433 -835
- package/lib/index.js.map +1 -1
- package/package.json +11 -8
- package/src/components/breadcrumb/component.js +29 -29
- package/src/components/button/index.js +1 -1
- package/src/components/button/lunatic-button.js +32 -0
- package/src/components/checkbox/checkbox-boolean/index.js +1 -0
- package/src/components/checkbox/checkbox-boolean/lunatic-checkbox-boolean.js +44 -0
- package/src/components/checkbox/checkbox-group/checkbox-group.js +78 -0
- package/src/components/checkbox/checkbox-group/checkbox-option.js +46 -0
- package/src/components/checkbox/checkbox-group/index.js +1 -0
- package/src/components/checkbox/checkbox-group/lunatic-checkbox-group.js +32 -0
- package/src/components/checkbox/checkbox-one/index.js +1 -0
- package/src/components/checkbox/checkbox-one/lunatic-checkbox-one.js +7 -0
- package/src/components/checkbox/checkbox.scss +1 -73
- package/src/components/checkbox/commons/checkbox-option.js +49 -0
- package/src/components/checkbox/commons/index.js +1 -0
- package/src/components/checkbox/index.js +3 -3
- package/src/components/commons/components/field-container/field-container.js +28 -0
- package/src/components/commons/components/field-container/field-container.scss +0 -0
- package/src/components/commons/components/field-container/index.js +1 -0
- package/src/components/commons/components/fieldset.js +12 -0
- package/src/components/commons/components/input-container.js +30 -0
- package/src/components/commons/components/label.js +14 -0
- package/src/components/commons/components/lunatic-field.js +35 -0
- package/src/components/commons/create-customizable-field.js +13 -0
- package/src/components/commons/index.js +9 -0
- package/src/components/commons/use-on-handle-change.js +16 -0
- package/src/components/commons/use-options-keydown.js +22 -0
- package/src/components/commons/use-previous.js +11 -0
- package/src/components/component-wrapper/controls/component.js +70 -0
- package/src/components/component-wrapper/controls/controls.scss +6 -0
- package/src/components/component-wrapper/controls/index.js +1 -0
- package/src/components/component-wrapper/controls/validators/datepicker.js +33 -0
- package/src/components/component-wrapper/controls/validators/index.js +16 -0
- package/src/components/component-wrapper/controls/validators/input-number.js +23 -0
- package/src/components/{missing-wrapper → component-wrapper}/index.js +1 -1
- package/src/components/{missing-wrapper → component-wrapper/missing}/component.js +72 -12
- package/src/components/component-wrapper/missing/index.js +1 -0
- package/src/components/{missing-wrapper → component-wrapper/missing}/missing.scss +0 -0
- package/src/components/component-wrapper/wrapper.js +23 -0
- package/src/components/components.js +22 -18
- package/src/components/datepicker/datepicker.js +25 -0
- package/src/components/datepicker/index.js +1 -1
- package/src/components/datepicker/lunatic-datepicker.js +50 -0
- package/src/components/declarations/declaration.js +11 -0
- package/src/components/declarations/declarations-after-text.js +8 -0
- package/src/components/declarations/declarations-before-text.js +8 -0
- package/src/components/declarations/declarations-detachable.js +8 -0
- package/src/components/declarations/declarations.js +35 -0
- package/src/components/declarations/index.js +4 -1
- package/src/components/declarations/wrappers/input-declarations-wrapper.js +40 -12
- package/src/components/declarations/wrappers/list-declarations-wrapper.js +235 -232
- package/src/components/dropdown/commons/actions.js +40 -31
- package/src/components/dropdown/commons/components/panel.js +78 -78
- package/src/components/dropdown/commons/reducer.js +152 -149
- package/src/components/dropdown/component.js +121 -115
- package/src/components/dropdown/dropdown-edit/dropdown-edit.js +6 -0
- package/src/components/dropdown/dropdown-simple/dropdown.js +8 -1
- package/src/components/filter-description/component.js +48 -42
- package/src/components/icon/component.js +31 -33
- package/src/components/index.scss +5 -3
- package/src/components/input/index.js +1 -2
- package/src/components/input/input.js +45 -9
- package/src/components/input/input.scss +0 -6
- package/src/components/input/lunatic-input.js +53 -0
- package/src/components/input-number/index.js +1 -0
- package/src/components/input-number/input-number.js +38 -0
- package/src/components/input-number/input-number.scss +0 -0
- package/src/components/input-number/lunatic-input-number.js +50 -0
- package/src/components/loop/{component.js → _old/component.js} +1 -0
- package/src/components/loop/{loop.scss → _old/loop.scss} +0 -0
- package/src/components/loop/{wrapper.js → _old/wrapper.js} +15 -15
- package/src/components/loop/block-for-loop/block-for-loop-ochestrator.js +6 -0
- package/src/components/loop/block-for-loop/block-for-loop.js +91 -0
- package/src/components/loop/block-for-loop/index.js +1 -0
- package/src/components/loop/block-for-loop/row.js +52 -0
- package/src/components/loop/commons/create-loop-orchestrator.js +36 -0
- package/src/components/loop/commons/index.js +2 -0
- package/src/components/loop/commons/row-component.js +52 -0
- package/src/components/loop/index.js +1 -1
- package/src/components/loop/loop.js +78 -0
- package/src/components/loop/roster-for-loop/add-row-button.js +12 -0
- package/src/components/loop/roster-for-loop/body.js +44 -0
- package/src/components/loop/roster-for-loop/header.js +25 -0
- package/src/components/loop/roster-for-loop/html-table/table.js +11 -0
- package/src/components/loop/roster-for-loop/html-table/tbody.js +11 -0
- package/src/components/loop/roster-for-loop/html-table/td.js +14 -0
- package/src/components/loop/roster-for-loop/html-table/th.js +11 -0
- package/src/components/loop/roster-for-loop/html-table/thead.js +11 -0
- package/src/components/loop/roster-for-loop/html-table/tr.js +11 -0
- package/src/components/loop/roster-for-loop/index.js +1 -0
- package/src/components/loop/roster-for-loop/roster-for-loop-orchestrator.js +6 -0
- package/src/components/loop/roster-for-loop/roster-for-loop.js +90 -0
- package/src/components/loop/roster-for-loop/roster-table.js +39 -0
- package/src/components/loop/roster-for-loop/roster.scss +42 -0
- package/src/components/loop/roster-for-loop/row.js +65 -0
- package/src/components/loop-constructor/block/component.js +2 -2
- package/src/components/loop-constructor/block/index.js +1 -1
- package/src/components/loop-constructor/index.js +1 -1
- package/src/components/loop-constructor/roster/component.js +2 -2
- package/src/components/loop-constructor/roster/index.js +1 -1
- package/src/components/loop-constructor/wrapper/body-component.js +6 -0
- package/src/components/loop-constructor/wrapper/build-components.js +33 -33
- package/src/components/loop-constructor/wrapper/index.js +1 -1
- package/src/components/modal/component.js +42 -0
- package/src/components/modal/index.js +1 -0
- package/src/components/modal/modal.scss +33 -0
- package/src/components/radio/index.js +1 -1
- package/src/components/radio/lunatic-radio-group.js +45 -0
- package/src/components/radio/radio-group.js +33 -0
- package/src/components/radio/radio-option.js +87 -0
- package/src/components/radio/radio.scss +52 -52
- package/src/components/sequence/index.js +1 -1
- package/src/components/sequence/sequence.js +75 -0
- package/src/components/subsequence/index.js +1 -1
- package/src/components/subsequence/subsequence.js +73 -0
- package/src/components/suggester/check-store.js +70 -70
- package/src/components/suggester/components/panel/option-container.js +11 -10
- package/src/components/suggester/components/panel/panel.js +20 -6
- package/src/components/suggester/components/selection/label.js +7 -6
- package/src/components/suggester/components/selection/selection.js +36 -11
- package/src/components/suggester/components/suggester-content.js +35 -42
- package/src/components/suggester/components/suggester.js +45 -26
- package/src/components/suggester/{components/create-on-keydown-callback.js → create-on-keydown-callback.js} +28 -28
- package/src/components/suggester/find-best-label/find-best-label.js +3 -1
- package/src/components/suggester/idb-suggester.js +2 -1
- package/src/components/suggester/lunatic-suggester.js +48 -96
- package/src/components/suggester/searching/create-searching.js +3 -1
- package/src/components/suggester/suggester-wrapper.js +75 -9
- package/src/components/switch/index.js +1 -0
- package/src/components/switch/lunatic-switch.js +49 -0
- package/src/components/switch/switch.js +72 -0
- package/src/components/switch/switch.scss +47 -0
- package/src/components/table/table.js +164 -158
- package/src/components/textarea/component.js +11 -5
- package/src/components/tooltip/response.js +58 -52
- package/src/stories/checkbox-boolean/data-forced.json +48 -48
- package/src/stories/checkbox-group/data-vtl.json +102 -102
- package/src/stories/cleaning/cleaning.stories.js +39 -0
- package/src/stories/cleaning/simple-loop.json +911 -0
- package/src/stories/cleaning/simpsons.json +5839 -0
- package/src/stories/datepicker/data.json +45 -43
- package/src/stories/declarations/declarations.stories.js +20 -13
- package/src/stories/icons/icons.stories.js +24 -16
- package/src/stories/loop-constructor/README.md +27 -27
- package/src/stories/loop-constructor/data-input-forced.json +64 -64
- package/src/stories/loop-constructor/data-input.json +100 -100
- package/src/stories/loop-constructor/data-loop-forced.json +66 -66
- package/src/stories/loop-constructor/data-loop-static-forced.json +66 -66
- package/src/stories/loop-constructor/data-loop-static.json +81 -81
- package/src/stories/loop-constructor/data-loop.json +81 -81
- package/src/stories/loop-constructor/data-roster-forced.json +68 -68
- package/src/stories/loop-constructor/data-roster.json +83 -83
- package/src/stories/loop-constructor/loop-constructor.stories.js +180 -180
- package/src/stories/questionnaire/logement-queen.json +23234 -0
- package/src/stories/questionnaire/logement.json +22068 -26812
- package/src/stories/questionnaire/questionnaire.stories.js +86 -29
- package/src/stories/questionnaire/update-external/data.json +1 -0
- package/src/stories/questionnaire/update-external/questionnaire.json +75 -0
- package/src/stories/suggester/bailleurs-sociaux-2021/fetch-bailleurs.js +12 -0
- package/src/stories/suggester/bailleurs-sociaux-2021/index.js +1 -0
- package/src/stories/suggester/data-auto.json +1 -0
- package/src/stories/suggester/data.json +35 -2
- package/src/stories/suggester/lunatic-suggester-mui.scss +27 -0
- package/src/stories/suggester/suggester-material-ui.js +148 -0
- package/src/stories/suggester/suggester-workers.stories.js +48 -1
- package/src/stories/suggester/suggester.stories.js +27 -1
- package/src/stories/switch/README.md +31 -0
- package/src/stories/switch/SwitchMaterialUI.js +35 -0
- package/src/stories/switch/data-forced.json +48 -0
- package/src/stories/switch/data.json +80 -0
- package/src/stories/switch/switch.stories.js +78 -0
- package/src/stories/utils/custom-lunatic.scss +28 -23
- package/src/stories/utils/orchestrator.js +151 -58
- package/src/stories/utils/waiting/index.js +1 -0
- package/src/stories/utils/waiting/preloader.svg +1 -0
- package/src/stories/utils/waiting/waiting.js +21 -0
- package/src/stories/utils/waiting/waiting.scss +21 -0
- package/src/tests/sample.spec.js +5 -0
- package/src/utils/icons/checkbox-checked.icon.js +25 -0
- package/src/utils/icons/checkbox-unchecked.icon.js +25 -0
- package/src/utils/icons/radio-checked.icon.js +25 -0
- package/src/utils/icons/radio-unchecked.icon.js +25 -0
- package/src/utils/lib/controls/index.js +1 -0
- package/src/utils/lib/controls/utils.js +146 -0
- package/src/utils/lib/index.js +20 -19
- package/src/utils/lib/pagination/navigation/shared.js +7 -4
- package/src/utils/lib/responses.js +9 -7
- package/src/utils/lib/tooltip/build-response.js +53 -41
- package/src/utils/store-tools/auto-load.js +2 -1
- package/src/utils/store-tools/create/index.js +2 -1
- package/src/utils/store-tools/create/update-store-info.js +26 -26
- package/src/utils/store-tools/index.js +7 -5
- package/src/utils/suggester-workers/append-to-index/create-append-task.js +3 -1
- package/src/utils/suggester-workers/commons-tokenizer/create-entity-tokenizer.js +56 -0
- package/src/utils/suggester-workers/commons-tokenizer/create-fields-tokenizer.js +56 -0
- package/src/utils/suggester-workers/commons-tokenizer/create-filter-stop-words.js +11 -11
- package/src/utils/suggester-workers/commons-tokenizer/filters/compose-filters.js +10 -0
- package/src/utils/suggester-workers/commons-tokenizer/filters/create-filter-stop-words.js +17 -0
- package/src/utils/suggester-workers/commons-tokenizer/filters/create-filter-stop-words.spec.js +14 -0
- package/src/utils/suggester-workers/commons-tokenizer/filters/filter-accents.js +12 -0
- package/src/utils/suggester-workers/commons-tokenizer/filters/filter-accents.spec.js +12 -0
- package/src/utils/suggester-workers/commons-tokenizer/{filter-double.js → filters/filter-double.js} +0 -0
- package/src/utils/suggester-workers/commons-tokenizer/filters/filter-double.spec.js +20 -0
- package/src/utils/suggester-workers/commons-tokenizer/{filter-length.js → filters/filter-length.js} +0 -0
- package/src/utils/suggester-workers/commons-tokenizer/filters/filter-length.spec.js +18 -0
- package/src/utils/suggester-workers/commons-tokenizer/{filter-stemmer.js → filters/filter-stemmer.js} +2 -2
- package/src/utils/suggester-workers/commons-tokenizer/filters/filter-stemmer.spec.js +12 -0
- package/src/utils/suggester-workers/commons-tokenizer/filters/filter-synonyms.js +36 -0
- package/src/utils/suggester-workers/commons-tokenizer/filters/filter-synonyms.spec.js +12 -0
- package/src/utils/suggester-workers/commons-tokenizer/filters/filter-to-lower.js +10 -0
- package/src/utils/suggester-workers/commons-tokenizer/filters/filter-to-lower.spec.js +12 -0
- package/src/utils/suggester-workers/commons-tokenizer/filters/index.js +2 -0
- package/src/utils/suggester-workers/commons-tokenizer/{stop-words.js → filters/stop-words.js} +0 -0
- package/src/utils/suggester-workers/commons-tokenizer/index.js +6 -5
- package/src/utils/suggester-workers/commons-tokenizer/prepare-string-indexation.js +7 -3
- package/src/utils/suggester-workers/commons-tokenizer/soft-tokenizer.js +1 -1
- package/src/utils/suggester-workers/create-worker.js +55 -0
- package/src/utils/suggester-workers/find-best-label/tokenize.js +2 -5
- package/src/utils/suggester-workers/{query-parser → searching/query-parser}/index.js +0 -0
- package/src/utils/suggester-workers/searching/query-parser/query-parser-soft.js +7 -0
- package/src/utils/suggester-workers/{query-parser → searching/query-parser}/query-parser-soft.spec.js +0 -0
- package/src/utils/suggester-workers/searching/query-parser/query-parser-tokenized.js +34 -0
- package/src/utils/suggester-workers/searching/resolve-query-parser.js +2 -2
- package/src/utils/suggester-workers/searching/searching.js +2 -2
- package/src/utils/to-expose/{calculated-variables.js → _old/calculated-variables.js} +0 -0
- package/src/utils/to-expose/{handler.js → _old/handler.js} +22 -0
- package/src/utils/to-expose/{init-questionnaire.js → _old/init-questionnaire.js} +0 -0
- package/src/utils/to-expose/{state.js → _old/state.js} +13 -14
- package/src/utils/to-expose/hooks/filter-components.js +106 -106
- package/src/utils/to-expose/hooks/index.js +1 -1
- package/src/utils/to-expose/hooks/lunatic.js +68 -7
- package/src/utils/to-expose/hooks/use-lunatic/actions.js +23 -0
- package/src/utils/to-expose/hooks/use-lunatic/commons/check-loops.js +61 -0
- package/src/utils/to-expose/hooks/use-lunatic/commons/create-map-pages.js +69 -0
- package/src/utils/to-expose/hooks/use-lunatic/commons/execute-condition-filter.js +16 -0
- package/src/utils/to-expose/hooks/use-lunatic/commons/execute-expression/create-execute-expression.js +182 -0
- package/src/utils/to-expose/hooks/use-lunatic/commons/execute-expression/create-memoizer.js +42 -0
- package/src/utils/to-expose/hooks/use-lunatic/commons/execute-expression/create-refresh-calculated.js +50 -0
- package/src/utils/to-expose/hooks/use-lunatic/commons/execute-expression/execute-expression.js +60 -0
- package/src/utils/to-expose/hooks/use-lunatic/commons/execute-expression/get-expressions-variables.js +22 -0
- package/src/utils/to-expose/hooks/use-lunatic/commons/execute-expression/index.js +1 -0
- package/src/utils/to-expose/hooks/use-lunatic/commons/fill-component-expressions.js +113 -0
- package/src/utils/to-expose/hooks/use-lunatic/commons/fill-components.js +31 -0
- package/src/utils/to-expose/hooks/use-lunatic/commons/get-compatible-vtl-expression.js +14 -0
- package/src/utils/to-expose/hooks/use-lunatic/commons/get-component-value/get-component-value.js +161 -0
- package/src/utils/to-expose/hooks/use-lunatic/commons/get-component-value/index.js +1 -0
- package/src/utils/to-expose/hooks/use-lunatic/commons/get-components-from-state.js +24 -0
- package/src/utils/to-expose/hooks/use-lunatic/commons/get-page-tag.js +10 -0
- package/src/utils/to-expose/hooks/use-lunatic/commons/index.js +12 -0
- package/src/utils/to-expose/hooks/use-lunatic/commons/is-First-last-page.js +8 -0
- package/src/utils/to-expose/hooks/use-lunatic/commons/is-paginated-loop.js +6 -0
- package/src/utils/to-expose/hooks/use-lunatic/commons/load-suggesters.js +59 -0
- package/src/utils/to-expose/hooks/use-lunatic/commons/use-components-from-state.js +20 -0
- package/src/utils/to-expose/hooks/use-lunatic/index.js +1 -0
- package/src/utils/to-expose/hooks/use-lunatic/initial-state.js +22 -0
- package/src/utils/to-expose/hooks/use-lunatic/reducer/commons/index.js +3 -0
- package/src/utils/to-expose/hooks/use-lunatic/reducer/commons/is-empty-on-empty-page.js +29 -0
- package/src/utils/to-expose/hooks/use-lunatic/reducer/commons/resize-array-variable.js +26 -0
- package/src/utils/to-expose/hooks/use-lunatic/reducer/commons/validate-loop-condition-filter.js +20 -0
- package/src/utils/to-expose/hooks/use-lunatic/reducer/index.js +1 -0
- package/src/utils/to-expose/hooks/use-lunatic/reducer/reduce-go-next-page.js +129 -0
- package/src/utils/to-expose/hooks/use-lunatic/reducer/reduce-go-previous-page.js +131 -0
- package/src/utils/to-expose/hooks/use-lunatic/reducer/reduce-handle-change/index.js +1 -0
- package/src/utils/to-expose/hooks/use-lunatic/reducer/reduce-handle-change/reduce-handle-change.js +69 -0
- package/src/utils/to-expose/hooks/use-lunatic/reducer/reduce-handle-change/reduce-variables-array.js +22 -0
- package/src/utils/to-expose/hooks/use-lunatic/reducer/reduce-handle-change/reduce-variables-simple.js +13 -0
- package/src/utils/to-expose/hooks/use-lunatic/reducer/reduce-on-init.js +166 -0
- package/src/utils/to-expose/hooks/use-lunatic/reducer/reduce-on-set-waiting.js +7 -0
- package/src/utils/to-expose/hooks/use-lunatic/reducer/reducer.js +26 -0
- package/src/utils/to-expose/hooks/use-lunatic/use-lunatic.js +79 -0
- package/src/utils/to-expose/index.js +16 -11
- package/src/components/button/component.js +0 -53
- package/src/components/checkbox/boolean.js +0 -172
- package/src/components/checkbox/group.js +0 -231
- package/src/components/checkbox/one.js +0 -11
- package/src/components/datepicker/component.js +0 -11
- package/src/components/input/input-number.js +0 -54
- package/src/components/missing-wrapper/wrapper.js +0 -10
- package/src/components/radio/component.js +0 -9
- package/src/components/sequence/component.js +0 -50
- package/src/components/subsequence/component.js +0 -49
- package/src/tests/components/breadcrumb.spec.js +0 -13
- package/src/tests/components/button.spec.js +0 -11
- package/src/tests/components/checkbox-boolean.spec.js +0 -45
- package/src/tests/components/checkbox-group.spec.js +0 -53
- package/src/tests/components/checkbox-one.spec.js +0 -32
- package/src/tests/components/datepicker.spec.js +0 -22
- package/src/tests/components/declarations-wrappers/input-declarations-wrapper.spec.js +0 -67
- package/src/tests/components/declarations-wrappers/list-declarations-wrapper.spec.js +0 -52
- package/src/tests/components/declarations-wrappers/simple-declarations-wrapper.spec.js +0 -21
- package/src/tests/components/declarations.spec.js +0 -46
- package/src/tests/components/input-number.spec.js +0 -194
- package/src/tests/components/input.spec.js +0 -18
- package/src/tests/components/loops/loop-static.json +0 -66
- package/src/tests/components/loops/loop.json +0 -258
- package/src/tests/components/loops/loop.spec.js +0 -30
- package/src/tests/components/loops/roster-for-loop.spec.js +0 -18
- package/src/tests/components/loops/roster-loop.json +0 -71
- package/src/tests/components/missing-wrapper.spec.js +0 -33
- package/src/tests/components/progress-bar.spec.js +0 -15
- package/src/tests/components/radio.spec.js +0 -27
- package/src/tests/components/sequence.spec.js +0 -9
- package/src/tests/components/subsequence.spec.js +0 -9
- package/src/tests/components/table.spec.js +0 -11
- package/src/tests/components/textarea.spec.js +0 -18
- package/src/tests/components/tooltip.spec.js +0 -25
- package/src/tests/setup/setupTests.js +0 -4
- package/src/tests/utils/lib/alphabet.spec.js +0 -36
- package/src/tests/utils/lib/array.spec.js +0 -22
- package/src/tests/utils/lib/checkbox/group.spec.js +0 -72
- package/src/tests/utils/lib/decorator/title-decorator.spec.js +0 -12
- package/src/tests/utils/lib/input-number.spec.js +0 -18
- package/src/tests/utils/lib/items-positioning.spec.js +0 -17
- package/src/tests/utils/lib/label-position.spec.js +0 -22
- package/src/tests/utils/lib/loops/bindings.spec.js +0 -75
- package/src/tests/utils/lib/loops/shared.spec.js +0 -82
- package/src/tests/utils/lib/missing/missing.spec.js +0 -74
- package/src/tests/utils/lib/missing/mock.js +0 -137
- package/src/tests/utils/lib/pagination/shared.spec.js +0 -42
- package/src/tests/utils/lib/responses.spec.js +0 -64
- package/src/tests/utils/lib/style.spec.js +0 -26
- package/src/tests/utils/lib/table/roster.spec.js +0 -25
- package/src/tests/utils/lib/tooltip/build-response.spec.js +0 -95
- package/src/tests/utils/lib/tooltip/content.spec.js +0 -109
- package/src/tests/utils/to-expose/handler/handler.spec.js +0 -94
- package/src/tests/utils/to-expose/handler/questionnaire.json +0 -158
- package/src/tests/utils/to-expose/handler/results/index.js +0 -6
- package/src/tests/utils/to-expose/handler/results/res-double.json +0 -158
- package/src/tests/utils/to-expose/handler/results/res-input-collected.json +0 -158
- package/src/tests/utils/to-expose/handler/results/res-input-edited.json +0 -158
- package/src/tests/utils/to-expose/handler/results/res-loop.json +0 -158
- package/src/tests/utils/to-expose/handler/results/res-matrix.json +0 -158
- package/src/tests/utils/to-expose/handler/results/res-responses.json +0 -158
- package/src/tests/utils/to-expose/hooks/use-lunatic.spec.js +0 -46
- package/src/tests/utils/to-expose/init-questionnaire/data.json +0 -12
- package/src/tests/utils/to-expose/init-questionnaire/init-questionnaire.spec.js +0 -19
- package/src/tests/utils/to-expose/init-questionnaire/questionnaire.json +0 -148
- package/src/tests/utils/to-expose/init-questionnaire/result.json +0 -181
- package/src/tests/utils/to-expose/interpret/interpret.spec.js +0 -48
- package/src/tests/utils/to-expose/state/questionnaire.json +0 -61
- package/src/tests/utils/to-expose/state/results.js +0 -78
- package/src/tests/utils/to-expose/state/state.spec.js +0 -59
- package/src/utils/suggester-workers/commons-tokenizer/create-tokenizer.js +0 -103
- package/src/utils/suggester-workers/commons-tokenizer/filter-accents-to-lower.js +0 -9
- package/src/utils/suggester-workers/commons-tokenizer/filter-synonyms.js +0 -10
- package/src/utils/suggester-workers/query-parser/query-parser-soft.js +0 -7
- package/src/utils/suggester-workers/query-parser/query-parser-tokenized.js +0 -31
- package/src/utils/suggester-workers/query-parser/query-parser-tokenized.spec.js +0 -32
|
@@ -1,53 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import {
|
|
4
|
-
buildStyleObject,
|
|
5
|
-
createObjectEvent,
|
|
6
|
-
isFunction,
|
|
7
|
-
} from '../../utils/lib';
|
|
8
|
-
import './button.scss';
|
|
9
|
-
import { BUTTON_CATEGORY, EVENT_CLICK } from '../../constants';
|
|
10
|
-
|
|
11
|
-
const Button = ({
|
|
12
|
-
label,
|
|
13
|
-
value,
|
|
14
|
-
onClick,
|
|
15
|
-
disabled,
|
|
16
|
-
style,
|
|
17
|
-
logFunction,
|
|
18
|
-
id,
|
|
19
|
-
}) => {
|
|
20
|
-
const handleClick = (e) => {
|
|
21
|
-
onClick(e);
|
|
22
|
-
if (isFunction(logFunction))
|
|
23
|
-
logFunction(
|
|
24
|
-
createObjectEvent(
|
|
25
|
-
`button-lunatic-${id}`,
|
|
26
|
-
BUTTON_CATEGORY,
|
|
27
|
-
EVENT_CLICK,
|
|
28
|
-
null,
|
|
29
|
-
label
|
|
30
|
-
)
|
|
31
|
-
);
|
|
32
|
-
};
|
|
33
|
-
return (
|
|
34
|
-
<button
|
|
35
|
-
type="button"
|
|
36
|
-
aria-label={label || 'button'}
|
|
37
|
-
className="button-lunatic"
|
|
38
|
-
style={buildStyleObject(style)}
|
|
39
|
-
disabled={disabled}
|
|
40
|
-
onClick={handleClick}
|
|
41
|
-
>
|
|
42
|
-
{value}
|
|
43
|
-
</button>
|
|
44
|
-
);
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
Button.propTypes = {
|
|
48
|
-
value: PropTypes.oneOfType([PropTypes.string, PropTypes.element]).isRequired,
|
|
49
|
-
disabled: PropTypes.bool,
|
|
50
|
-
onClick: PropTypes.func.isRequired,
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
export default Button;
|
|
@@ -1,172 +0,0 @@
|
|
|
1
|
-
import React, { useState, useEffect, useRef } from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import missingWrapper from '../missing-wrapper';
|
|
4
|
-
import debounce from 'lodash.debounce';
|
|
5
|
-
import Declarations from '../declarations';
|
|
6
|
-
import Icon from '../icon';
|
|
7
|
-
import { TooltipResponse } from '../tooltip';
|
|
8
|
-
import * as U from '../../utils/lib';
|
|
9
|
-
import * as C from '../../constants';
|
|
10
|
-
import { interpret } from '../../utils/to-expose';
|
|
11
|
-
import './checkbox.scss';
|
|
12
|
-
|
|
13
|
-
const CheckboxBoolean = ({
|
|
14
|
-
id,
|
|
15
|
-
label,
|
|
16
|
-
preferences,
|
|
17
|
-
response,
|
|
18
|
-
handleChange: propsHandleChange,
|
|
19
|
-
disabled,
|
|
20
|
-
positioning,
|
|
21
|
-
focused,
|
|
22
|
-
declarations,
|
|
23
|
-
features,
|
|
24
|
-
bindings,
|
|
25
|
-
management,
|
|
26
|
-
style,
|
|
27
|
-
logFunction,
|
|
28
|
-
}) => {
|
|
29
|
-
const inputRef = useRef();
|
|
30
|
-
|
|
31
|
-
const [value, setValue] = useState(() =>
|
|
32
|
-
U.getResponseByPreference(preferences)(response)
|
|
33
|
-
);
|
|
34
|
-
|
|
35
|
-
const handleChange = debounce((obj) => propsHandleChange(obj), 50);
|
|
36
|
-
|
|
37
|
-
const specificHandleChange = (e) => {
|
|
38
|
-
const [key, value] = Object.entries(e)[0];
|
|
39
|
-
if (value === false && U.responseToClean(response)(preferences))
|
|
40
|
-
handleChange({ [key]: null });
|
|
41
|
-
else handleChange(e);
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
// Assume we only want to handle enable external updates
|
|
45
|
-
// Don't need to check all value changes
|
|
46
|
-
useEffect(() => {
|
|
47
|
-
if (U.getResponseByPreference(preferences)(response) !== value)
|
|
48
|
-
setValue(U.getResponseByPreference(preferences)(response));
|
|
49
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
50
|
-
}, [response, preferences]);
|
|
51
|
-
|
|
52
|
-
useEffect(() => {
|
|
53
|
-
if (focused) inputRef.current.focus();
|
|
54
|
-
}, [focused]);
|
|
55
|
-
|
|
56
|
-
const interpretedLabel = interpret(features, logFunction)(bindings)(label);
|
|
57
|
-
|
|
58
|
-
const isVertical = positioning === 'VERTICAL';
|
|
59
|
-
const isHorizontal = positioning === 'HORIZONTAL';
|
|
60
|
-
const input = (
|
|
61
|
-
<>
|
|
62
|
-
<Icon type="checkbox" checked={value} disabled={disabled}>
|
|
63
|
-
<input
|
|
64
|
-
type="checkbox"
|
|
65
|
-
id={`checkbox-boolean-${id}`}
|
|
66
|
-
ref={inputRef}
|
|
67
|
-
title={interpretedLabel ? interpretedLabel : 'empty-label'}
|
|
68
|
-
className={`checkbox-boolean-lunatic`}
|
|
69
|
-
style={U.buildStyleObject(style)}
|
|
70
|
-
checked={value || false}
|
|
71
|
-
disabled={disabled}
|
|
72
|
-
onChange={({ target: { checked } }) => {
|
|
73
|
-
setValue(checked);
|
|
74
|
-
specificHandleChange({
|
|
75
|
-
[U.getResponseName(response)]: checked,
|
|
76
|
-
});
|
|
77
|
-
if (U.isFunction(logFunction))
|
|
78
|
-
logFunction(
|
|
79
|
-
U.createObjectEvent(
|
|
80
|
-
`checkbox-boolean-${id}`,
|
|
81
|
-
C.INPUT_CATEGORY,
|
|
82
|
-
C.EVENT_SELECTION,
|
|
83
|
-
U.getResponseName(response),
|
|
84
|
-
checked
|
|
85
|
-
)
|
|
86
|
-
);
|
|
87
|
-
}}
|
|
88
|
-
/>
|
|
89
|
-
{interpretedLabel && (
|
|
90
|
-
<label htmlFor={`checkbox-boolean-${id}`}>
|
|
91
|
-
{isHorizontal ? interpretedLabel : ''}
|
|
92
|
-
</label>
|
|
93
|
-
)}
|
|
94
|
-
</Icon>
|
|
95
|
-
</>
|
|
96
|
-
);
|
|
97
|
-
return (
|
|
98
|
-
<div key={`checkbox-boolean-${id}`} className={`checkbox-boolean-modality`}>
|
|
99
|
-
<Declarations
|
|
100
|
-
id={id}
|
|
101
|
-
type={C.BEFORE_QUESTION_TEXT}
|
|
102
|
-
declarations={declarations}
|
|
103
|
-
features={features}
|
|
104
|
-
bindings={bindings}
|
|
105
|
-
/>
|
|
106
|
-
{label && !isHorizontal && (
|
|
107
|
-
<label htmlFor={`checkbox-boolean-${id}`}>
|
|
108
|
-
{interpret(features, logFunction)(bindings)(label)}
|
|
109
|
-
</label>
|
|
110
|
-
)}
|
|
111
|
-
<Declarations
|
|
112
|
-
id={id}
|
|
113
|
-
type={C.AFTER_QUESTION_TEXT}
|
|
114
|
-
declarations={declarations}
|
|
115
|
-
features={features}
|
|
116
|
-
bindings={bindings}
|
|
117
|
-
/>
|
|
118
|
-
<div className="field-container">
|
|
119
|
-
<div className={`${management ? 'field-with-tooltip' : 'field'}`}>
|
|
120
|
-
{isVertical ? <div>{input}</div> : input}
|
|
121
|
-
</div>
|
|
122
|
-
{management && (
|
|
123
|
-
<div className="tooltip">
|
|
124
|
-
<TooltipResponse
|
|
125
|
-
id={id}
|
|
126
|
-
response={U.buildBooleanTooltipResponse(response)}
|
|
127
|
-
/>
|
|
128
|
-
</div>
|
|
129
|
-
)}
|
|
130
|
-
</div>
|
|
131
|
-
<Declarations
|
|
132
|
-
id={id}
|
|
133
|
-
type={C.DETACHABLE}
|
|
134
|
-
declarations={declarations}
|
|
135
|
-
features={features}
|
|
136
|
-
bindings={bindings}
|
|
137
|
-
/>
|
|
138
|
-
</div>
|
|
139
|
-
);
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
CheckboxBoolean.defaultProps = {
|
|
143
|
-
label: '',
|
|
144
|
-
preferences: ['COLLECTED'],
|
|
145
|
-
response: {},
|
|
146
|
-
disabled: false,
|
|
147
|
-
positioning: 'DEFAULT',
|
|
148
|
-
focused: false,
|
|
149
|
-
declarations: [],
|
|
150
|
-
features: [],
|
|
151
|
-
bindings: {},
|
|
152
|
-
management: false,
|
|
153
|
-
style: {},
|
|
154
|
-
};
|
|
155
|
-
|
|
156
|
-
CheckboxBoolean.propTypes = {
|
|
157
|
-
id: PropTypes.string.isRequired,
|
|
158
|
-
label: PropTypes.string,
|
|
159
|
-
preferences: PropTypes.arrayOf(U.valueTypePropTypes),
|
|
160
|
-
response: U.responsePropTypes,
|
|
161
|
-
handleChange: PropTypes.func.isRequired,
|
|
162
|
-
disabled: PropTypes.bool,
|
|
163
|
-
positioning: PropTypes.oneOf(['DEFAULT', 'HORIZONTAL', 'VERTICAL']),
|
|
164
|
-
focused: PropTypes.bool,
|
|
165
|
-
declarations: U.declarationsPropTypes,
|
|
166
|
-
features: PropTypes.arrayOf(PropTypes.string),
|
|
167
|
-
bindings: PropTypes.object,
|
|
168
|
-
management: PropTypes.bool,
|
|
169
|
-
style: PropTypes.object,
|
|
170
|
-
};
|
|
171
|
-
|
|
172
|
-
export default missingWrapper(React.memo(CheckboxBoolean, U.areEqual));
|
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
import React, { useState, useRef, useEffect } from 'react';
|
|
2
|
-
import KeyboardEventHandler from 'react-keyboard-event-handler';
|
|
3
|
-
import PropTypes from 'prop-types';
|
|
4
|
-
import missingWrapper from '../missing-wrapper';
|
|
5
|
-
import debounce from 'lodash.debounce';
|
|
6
|
-
import Declarations from '../declarations';
|
|
7
|
-
import Icon from '../icon';
|
|
8
|
-
import { TooltipResponse } from '../tooltip';
|
|
9
|
-
import * as U from '../../utils/lib';
|
|
10
|
-
import * as C from '../../constants';
|
|
11
|
-
import { interpret } from '../../utils/to-expose';
|
|
12
|
-
import './checkbox.scss';
|
|
13
|
-
|
|
14
|
-
const CheckboxGroup = ({
|
|
15
|
-
id,
|
|
16
|
-
label,
|
|
17
|
-
preferences,
|
|
18
|
-
responses,
|
|
19
|
-
handleChange: propsHandleChange,
|
|
20
|
-
disabled,
|
|
21
|
-
focused,
|
|
22
|
-
shortcut,
|
|
23
|
-
positioning,
|
|
24
|
-
declarations,
|
|
25
|
-
features,
|
|
26
|
-
bindings,
|
|
27
|
-
management,
|
|
28
|
-
style,
|
|
29
|
-
logFunction,
|
|
30
|
-
}) => {
|
|
31
|
-
const { fieldsetStyle, modalityStyle } = style;
|
|
32
|
-
const inputRef = useRef();
|
|
33
|
-
|
|
34
|
-
const [values, setValues] = useState(() =>
|
|
35
|
-
responses.map(({ response }) =>
|
|
36
|
-
U.getResponseByPreference(preferences)(response)
|
|
37
|
-
)
|
|
38
|
-
);
|
|
39
|
-
|
|
40
|
-
const handleChange = debounce((obj) => propsHandleChange(obj), 50);
|
|
41
|
-
|
|
42
|
-
const specificHandleChange = (e) => {
|
|
43
|
-
const [key, value] = Object.entries(e)[0];
|
|
44
|
-
if (value === false && U.responsesToClean(responses)(preferences)(key))
|
|
45
|
-
handleChange({ [key]: null });
|
|
46
|
-
else handleChange(e);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
// Assume we only want to handle enable external updates
|
|
50
|
-
// Don't need to check all value changes
|
|
51
|
-
useEffect(() => {
|
|
52
|
-
const newValues = responses.map(({ response }) =>
|
|
53
|
-
U.getResponseByPreference(preferences)(response)
|
|
54
|
-
);
|
|
55
|
-
if (newValues.join('|') !== values.join('|')) setValues(newValues);
|
|
56
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
57
|
-
}, [responses, preferences]);
|
|
58
|
-
|
|
59
|
-
useEffect(() => {
|
|
60
|
-
if (focused) inputRef.current.focus();
|
|
61
|
-
}, [focused]);
|
|
62
|
-
|
|
63
|
-
const checkedArray = [];
|
|
64
|
-
|
|
65
|
-
return (
|
|
66
|
-
<>
|
|
67
|
-
<Declarations
|
|
68
|
-
id={id}
|
|
69
|
-
type={C.BEFORE_QUESTION_TEXT}
|
|
70
|
-
declarations={declarations}
|
|
71
|
-
features={features}
|
|
72
|
-
bindings={bindings}
|
|
73
|
-
/>
|
|
74
|
-
<fieldset
|
|
75
|
-
key={`checkbox-${id}`}
|
|
76
|
-
className="checkbox-group-list"
|
|
77
|
-
style={U.buildStyleObject(fieldsetStyle)}
|
|
78
|
-
>
|
|
79
|
-
<legend>{interpret(features, logFunction)(bindings)(label)}</legend>
|
|
80
|
-
<Declarations
|
|
81
|
-
id={id}
|
|
82
|
-
type={C.AFTER_QUESTION_TEXT}
|
|
83
|
-
declarations={declarations}
|
|
84
|
-
features={features}
|
|
85
|
-
bindings={bindings}
|
|
86
|
-
/>
|
|
87
|
-
{responses.map(({ id: modId, label: modLabel, response }, i) => {
|
|
88
|
-
const checked = values[i];
|
|
89
|
-
if (checked) checkedArray.push(modId);
|
|
90
|
-
const toRef =
|
|
91
|
-
i === 0 || (checkedArray[0] && checkedArray[0] === modId);
|
|
92
|
-
const interpretedLabel = interpret(features)(bindings)(modLabel);
|
|
93
|
-
const keyboardSelectionKey =
|
|
94
|
-
responses.length < 10 ? `${i + 1}` : U.getAlphabet()[i];
|
|
95
|
-
return (
|
|
96
|
-
<div
|
|
97
|
-
className={`${U.getItemsPositioningClass(positioning)}`}
|
|
98
|
-
key={`checkbox-${id}-${modId}`}
|
|
99
|
-
>
|
|
100
|
-
<div className="field-container">
|
|
101
|
-
<div
|
|
102
|
-
className={`${management ? 'field-with-tooltip' : 'field'}`}
|
|
103
|
-
>
|
|
104
|
-
<div
|
|
105
|
-
className={`checkbox-modality ${
|
|
106
|
-
checked ? 'content-checked' : ''
|
|
107
|
-
}`}
|
|
108
|
-
>
|
|
109
|
-
<Icon type="checkbox" checked={checked} disabled={disabled}>
|
|
110
|
-
<input
|
|
111
|
-
type="checkbox"
|
|
112
|
-
id={`checkbox-${id}-${modId}`}
|
|
113
|
-
ref={toRef ? inputRef : null}
|
|
114
|
-
key={`checkbox-${id}-${modId}`}
|
|
115
|
-
aria-labelledby={`input-label-${id}-${modId}`}
|
|
116
|
-
className="checkbox-lunatic"
|
|
117
|
-
checked={checked || false}
|
|
118
|
-
disabled={disabled}
|
|
119
|
-
onChange={({ target: { checked } }) => {
|
|
120
|
-
setValues(
|
|
121
|
-
values.map((v, j) => (i === j ? checked : v))
|
|
122
|
-
);
|
|
123
|
-
specificHandleChange({
|
|
124
|
-
[U.getResponseName(response)]: checked,
|
|
125
|
-
});
|
|
126
|
-
if (U.isFunction(logFunction))
|
|
127
|
-
logFunction(
|
|
128
|
-
U.createObjectEvent(
|
|
129
|
-
`checkbox-${id}-${modId}`,
|
|
130
|
-
C.INPUT_CATEGORY,
|
|
131
|
-
C.EVENT_SELECTION,
|
|
132
|
-
U.getResponseName(response),
|
|
133
|
-
checked
|
|
134
|
-
)
|
|
135
|
-
);
|
|
136
|
-
}}
|
|
137
|
-
/>
|
|
138
|
-
<label
|
|
139
|
-
htmlFor={`checkbox-${id}-${modId}`}
|
|
140
|
-
id={`input-label-${id}-${modId}`}
|
|
141
|
-
style={checked ? U.buildStyleObject(modalityStyle) : {}}
|
|
142
|
-
className="modality-label"
|
|
143
|
-
>
|
|
144
|
-
{shortcut && (
|
|
145
|
-
<span className="code-modality">
|
|
146
|
-
{keyboardSelectionKey.toUpperCase()}
|
|
147
|
-
</span>
|
|
148
|
-
)}
|
|
149
|
-
{interpretedLabel}
|
|
150
|
-
</label>
|
|
151
|
-
</Icon>
|
|
152
|
-
</div>
|
|
153
|
-
</div>
|
|
154
|
-
{management && (
|
|
155
|
-
<div className="tooltip">
|
|
156
|
-
<TooltipResponse
|
|
157
|
-
id={id}
|
|
158
|
-
response={U.buildBooleanTooltipResponse(response)}
|
|
159
|
-
/>
|
|
160
|
-
</div>
|
|
161
|
-
)}
|
|
162
|
-
</div>
|
|
163
|
-
{shortcut && (
|
|
164
|
-
<KeyboardEventHandler
|
|
165
|
-
handleKeys={[keyboardSelectionKey.toLowerCase()]}
|
|
166
|
-
onKeyEvent={(key, e) => {
|
|
167
|
-
e.preventDefault();
|
|
168
|
-
setValues(values.map((v, j) => (i === j ? !checked : v)));
|
|
169
|
-
specificHandleChange({
|
|
170
|
-
[U.getResponseName(response)]: !checked,
|
|
171
|
-
});
|
|
172
|
-
if (U.isFunction(logFunction))
|
|
173
|
-
logFunction(
|
|
174
|
-
U.createObjectEvent(
|
|
175
|
-
`checkbox-${id}-${modId}`,
|
|
176
|
-
C.INPUT_CATEGORY,
|
|
177
|
-
C.EVENT_SELECTION,
|
|
178
|
-
U.getResponseName(response),
|
|
179
|
-
!checked
|
|
180
|
-
)
|
|
181
|
-
);
|
|
182
|
-
}}
|
|
183
|
-
handleFocusableElements
|
|
184
|
-
/>
|
|
185
|
-
)}
|
|
186
|
-
</div>
|
|
187
|
-
);
|
|
188
|
-
})}
|
|
189
|
-
</fieldset>
|
|
190
|
-
<Declarations
|
|
191
|
-
id={id}
|
|
192
|
-
type={C.DETACHABLE}
|
|
193
|
-
declarations={declarations}
|
|
194
|
-
features={features}
|
|
195
|
-
bindings={bindings}
|
|
196
|
-
/>
|
|
197
|
-
</>
|
|
198
|
-
);
|
|
199
|
-
};
|
|
200
|
-
|
|
201
|
-
CheckboxGroup.defaultProps = {
|
|
202
|
-
label: '',
|
|
203
|
-
preferences: ['COLLECTED'],
|
|
204
|
-
responses: [],
|
|
205
|
-
disabled: false,
|
|
206
|
-
focused: false,
|
|
207
|
-
positioning: 'DEFAULT',
|
|
208
|
-
declarations: [],
|
|
209
|
-
features: [],
|
|
210
|
-
bindings: {},
|
|
211
|
-
management: false,
|
|
212
|
-
style: { fieldsetStyle: {}, modalityStyle: {} },
|
|
213
|
-
};
|
|
214
|
-
|
|
215
|
-
CheckboxGroup.propTypes = {
|
|
216
|
-
id: PropTypes.string.isRequired,
|
|
217
|
-
label: PropTypes.string,
|
|
218
|
-
preferences: PropTypes.arrayOf(U.valueTypePropTypes),
|
|
219
|
-
response: U.responsePropTypes,
|
|
220
|
-
handleChange: PropTypes.func.isRequired,
|
|
221
|
-
disabled: PropTypes.bool,
|
|
222
|
-
focused: PropTypes.bool,
|
|
223
|
-
positioning: PropTypes.oneOf(['DEFAULT', 'HORIZONTAL', 'VERTICAL']),
|
|
224
|
-
declarations: U.declarationsPropTypes,
|
|
225
|
-
features: PropTypes.arrayOf(PropTypes.string),
|
|
226
|
-
bindings: PropTypes.object,
|
|
227
|
-
management: PropTypes.bool,
|
|
228
|
-
style: PropTypes.object,
|
|
229
|
-
};
|
|
230
|
-
|
|
231
|
-
export default missingWrapper(React.memo(CheckboxGroup), U.areEqual);
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import missingWrapper from '../missing-wrapper';
|
|
3
|
-
import { ListDeclarationsWrapper } from '../declarations/wrappers';
|
|
4
|
-
import { areEqual } from '../../utils/lib';
|
|
5
|
-
import './checkbox.scss';
|
|
6
|
-
|
|
7
|
-
const CheckboxOne = (props) => (
|
|
8
|
-
<ListDeclarationsWrapper type="checkbox" {...props} hasSpecificHandler />
|
|
9
|
-
);
|
|
10
|
-
|
|
11
|
-
export default missingWrapper(React.memo(CheckboxOne, areEqual));
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import missingWrapper from '../missing-wrapper';
|
|
3
|
-
import { InputDeclarationsWrapper } from '../declarations/wrappers';
|
|
4
|
-
import { areEqual } from '../../utils/lib';
|
|
5
|
-
import './datepicker.scss';
|
|
6
|
-
|
|
7
|
-
const Datepicker = (props) => (
|
|
8
|
-
<InputDeclarationsWrapper type="date" roleType="datepicker" {...props} />
|
|
9
|
-
);
|
|
10
|
-
|
|
11
|
-
export default missingWrapper(React.memo(Datepicker, areEqual));
|
|
@@ -1,54 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import missingWrapper from '../missing-wrapper';
|
|
4
|
-
import { InputDeclarationsWrapper } from '../declarations/wrappers';
|
|
5
|
-
import { areEqual } from '../../utils/lib';
|
|
6
|
-
import './input.scss';
|
|
7
|
-
|
|
8
|
-
const InputNumber = ({ numberAsTextfield, ...props }) => {
|
|
9
|
-
const { min, max, validators } = props;
|
|
10
|
-
return (
|
|
11
|
-
<InputDeclarationsWrapper
|
|
12
|
-
type={numberAsTextfield ? 'text' : 'number'}
|
|
13
|
-
roleType="input"
|
|
14
|
-
{...props}
|
|
15
|
-
validators={[minMaxValidator({ min, max }), ...validators]}
|
|
16
|
-
isInputNumber
|
|
17
|
-
numberAsTextfield
|
|
18
|
-
/>
|
|
19
|
-
);
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
const minMaxValidator =
|
|
23
|
-
({ min, max }) =>
|
|
24
|
-
(value) => {
|
|
25
|
-
if (!value) {
|
|
26
|
-
return undefined;
|
|
27
|
-
}
|
|
28
|
-
const valueNumber = Number(value);
|
|
29
|
-
if (!min && isDef(max) && valueNumber > max)
|
|
30
|
-
return <span>{`La valeur doit être inférieure à ${max}`}</span>;
|
|
31
|
-
else if (isDef(min) && !max && valueNumber < min)
|
|
32
|
-
return <span>{`La valeur doit être supérieure à ${min}`}</span>;
|
|
33
|
-
else if (
|
|
34
|
-
isDef(min) &&
|
|
35
|
-
isDef(max) &&
|
|
36
|
-
(valueNumber < min || valueNumber > max)
|
|
37
|
-
)
|
|
38
|
-
return (
|
|
39
|
-
<span>{`La valeur doit être comprise entre ${min} et ${max}`}</span>
|
|
40
|
-
);
|
|
41
|
-
return undefined;
|
|
42
|
-
};
|
|
43
|
-
|
|
44
|
-
const isDef = (number) => number || number === 0;
|
|
45
|
-
|
|
46
|
-
InputNumber.defaultProps = {
|
|
47
|
-
validators: [],
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
InputNumber.propTypes = {
|
|
51
|
-
validators: PropTypes.arrayOf(PropTypes.func),
|
|
52
|
-
};
|
|
53
|
-
|
|
54
|
-
export default missingWrapper(React.memo(InputNumber, areEqual));
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import Missing from './component';
|
|
3
|
-
|
|
4
|
-
const missingWrapper = (Component) => (props) => {
|
|
5
|
-
const { missing } = props;
|
|
6
|
-
if (missing) return <Missing Component={Component} props={props} />;
|
|
7
|
-
return <Component {...props} />;
|
|
8
|
-
};
|
|
9
|
-
|
|
10
|
-
export default missingWrapper;
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import missingWrapper from '../missing-wrapper';
|
|
3
|
-
import { ListDeclarationsWrapper } from '../declarations/wrappers';
|
|
4
|
-
import { areEqual } from '../../utils/lib';
|
|
5
|
-
import './radio.scss';
|
|
6
|
-
|
|
7
|
-
const Radio = (props) => <ListDeclarationsWrapper type="radio" {...props} />;
|
|
8
|
-
|
|
9
|
-
export default missingWrapper(React.memo(Radio, areEqual));
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { SimpleDeclarationsWrapper } from '../declarations/wrappers';
|
|
4
|
-
import * as U from '../../utils/lib';
|
|
5
|
-
import { interpret } from '../../utils/to-expose';
|
|
6
|
-
import './sequence.scss';
|
|
7
|
-
|
|
8
|
-
const Sequence = ({
|
|
9
|
-
id,
|
|
10
|
-
label,
|
|
11
|
-
declarations,
|
|
12
|
-
features,
|
|
13
|
-
bindings,
|
|
14
|
-
style,
|
|
15
|
-
logFunction,
|
|
16
|
-
}) => (
|
|
17
|
-
<SimpleDeclarationsWrapper
|
|
18
|
-
id={id}
|
|
19
|
-
declarations={declarations}
|
|
20
|
-
features={features}
|
|
21
|
-
bindings={bindings}
|
|
22
|
-
>
|
|
23
|
-
<div
|
|
24
|
-
aria-label={`sequence-${id}`}
|
|
25
|
-
className="sequence-lunatic"
|
|
26
|
-
style={U.buildStyleObject(style)}
|
|
27
|
-
id={`sequence-${id}`}
|
|
28
|
-
>
|
|
29
|
-
{interpret(features, logFunction)(bindings)(label)}
|
|
30
|
-
</div>
|
|
31
|
-
</SimpleDeclarationsWrapper>
|
|
32
|
-
);
|
|
33
|
-
|
|
34
|
-
Sequence.defaultProps = {
|
|
35
|
-
declarations: [],
|
|
36
|
-
features: [],
|
|
37
|
-
bindings: {},
|
|
38
|
-
style: {},
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
Sequence.propTypes = {
|
|
42
|
-
id: PropTypes.string.isRequired,
|
|
43
|
-
label: PropTypes.string.isRequired,
|
|
44
|
-
declarations: U.declarationsPropTypes,
|
|
45
|
-
features: PropTypes.arrayOf(PropTypes.string),
|
|
46
|
-
bindings: PropTypes.object,
|
|
47
|
-
style: PropTypes.object,
|
|
48
|
-
};
|
|
49
|
-
|
|
50
|
-
export default React.memo(Sequence, U.areEqual);
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import PropTypes from 'prop-types';
|
|
3
|
-
import { SimpleDeclarationsWrapper } from '../declarations/wrappers';
|
|
4
|
-
import * as U from '../../utils/lib';
|
|
5
|
-
import { interpret } from '../../utils/to-expose';
|
|
6
|
-
|
|
7
|
-
const Subsequence = ({
|
|
8
|
-
id,
|
|
9
|
-
label,
|
|
10
|
-
declarations,
|
|
11
|
-
features,
|
|
12
|
-
bindings,
|
|
13
|
-
style,
|
|
14
|
-
logFunction,
|
|
15
|
-
}) => (
|
|
16
|
-
<SimpleDeclarationsWrapper
|
|
17
|
-
id={id}
|
|
18
|
-
declarations={declarations}
|
|
19
|
-
features={features}
|
|
20
|
-
bindings={bindings}
|
|
21
|
-
>
|
|
22
|
-
<div
|
|
23
|
-
aria-label={`subsequence-${id}`}
|
|
24
|
-
className="subsequence-lunatic"
|
|
25
|
-
style={U.buildStyleObject(style)}
|
|
26
|
-
aria-label={`subsequence-${id}`}
|
|
27
|
-
>
|
|
28
|
-
{interpret(features, logFunction)(bindings)(label)}
|
|
29
|
-
</div>
|
|
30
|
-
</SimpleDeclarationsWrapper>
|
|
31
|
-
);
|
|
32
|
-
|
|
33
|
-
Subsequence.defaultProps = {
|
|
34
|
-
declarations: [],
|
|
35
|
-
features: [],
|
|
36
|
-
bindings: {},
|
|
37
|
-
style: {},
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
Subsequence.propTypes = {
|
|
41
|
-
id: PropTypes.string.isRequired,
|
|
42
|
-
label: PropTypes.string.isRequired,
|
|
43
|
-
declarations: U.declarationsPropTypes,
|
|
44
|
-
features: PropTypes.arrayOf(PropTypes.string),
|
|
45
|
-
bindings: PropTypes.object,
|
|
46
|
-
style: PropTypes.object,
|
|
47
|
-
};
|
|
48
|
-
|
|
49
|
-
export default React.memo(Subsequence, U.areEqual);
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
import { Breadcrumb } from 'components';
|
|
4
|
-
|
|
5
|
-
describe('breadcrumb', () => {
|
|
6
|
-
it('renders without crashing', () => {
|
|
7
|
-
shallow(<Breadcrumb elements={[]} />);
|
|
8
|
-
});
|
|
9
|
-
it('renders with elements', () => {
|
|
10
|
-
const wrapper = shallow(<Breadcrumb elements={['One', 'Two']} />);
|
|
11
|
-
expect(wrapper.find('.breadcrumb-lunatic').children()).toHaveLength(2);
|
|
12
|
-
});
|
|
13
|
-
});
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import { shallow } from 'enzyme';
|
|
3
|
-
import { Button } from 'components';
|
|
4
|
-
|
|
5
|
-
describe('button', () => {
|
|
6
|
-
const onClick = jest.fn();
|
|
7
|
-
|
|
8
|
-
it('renders without crashing', () => {
|
|
9
|
-
shallow(<Button value="Button" onClick={onClick} />);
|
|
10
|
-
});
|
|
11
|
-
});
|