@inseefr/lunatic 2.0.2 → 2.0.3-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/LICENSE +21 -21
- package/README.md +25 -22
- package/lib/components/button/button.scss +24 -0
- package/lib/components/button/index.js +15 -0
- package/lib/components/button/lunatic-button.js +66 -0
- package/lib/components/checkbox/checkbox-boolean/checkbox-boolean.js +36 -0
- package/lib/components/checkbox/checkbox-boolean/index.js +15 -0
- package/lib/components/checkbox/checkbox-boolean/lunatic-checkbox-boolean.js +48 -0
- package/lib/components/checkbox/checkbox-group/checkbox-group.js +96 -0
- package/lib/components/checkbox/checkbox-group/checkbox.scss +4 -0
- package/lib/components/checkbox/checkbox-group/index.js +15 -0
- package/lib/components/checkbox/checkbox-group/lunatic-checkbox-group.js +42 -0
- package/lib/components/checkbox/checkbox-one/index.js +15 -0
- package/lib/components/checkbox/checkbox-one/lunatic-checkbox-one.js +39 -0
- package/lib/components/checkbox/commons/checkbox-option.js +68 -0
- package/lib/components/checkbox/commons/checkbox-option.scss +3 -0
- package/lib/components/checkbox/commons/index.js +15 -0
- package/lib/components/checkbox/index.js +31 -0
- package/lib/components/commons/build-style-object.js +36 -0
- package/lib/components/commons/components/combo-box/combo-box-container.js +37 -0
- package/lib/components/commons/components/combo-box/combo-box-content.js +73 -0
- package/lib/components/commons/components/combo-box/combo-box.js +222 -0
- package/lib/components/commons/components/combo-box/combo-box.scss +205 -0
- package/lib/components/commons/components/combo-box/index.js +15 -0
- package/lib/components/commons/components/combo-box/panel/index.js +15 -0
- package/lib/components/commons/components/combo-box/panel/option-container.js +77 -0
- package/lib/components/commons/components/combo-box/panel/panel-container.js +31 -0
- package/lib/components/commons/components/combo-box/panel/panel.js +70 -0
- package/lib/components/commons/components/combo-box/selection/delete.js +69 -0
- package/lib/components/commons/components/combo-box/selection/displayLabelOrInput.js +30 -0
- package/lib/components/commons/components/combo-box/selection/index.js +15 -0
- package/lib/components/commons/components/combo-box/selection/input.js +68 -0
- package/lib/components/commons/components/combo-box/selection/label-selection.js +39 -0
- package/lib/components/commons/components/combo-box/selection/selection-container.js +40 -0
- package/lib/components/commons/components/combo-box/selection/selection.js +71 -0
- package/lib/components/commons/components/combo-box/state-management/actions.js +98 -0
- package/lib/components/commons/components/combo-box/state-management/combo-box-context.js +20 -0
- package/lib/components/commons/components/combo-box/state-management/index.js +42 -0
- package/lib/components/commons/components/combo-box/state-management/initial-state.js +14 -0
- package/lib/components/commons/components/combo-box/state-management/reducer/index.js +15 -0
- package/lib/components/commons/components/combo-box/state-management/reducer/reduce-on-blur.js +22 -0
- package/lib/components/commons/components/combo-box/state-management/reducer/reduce-on-change.js +24 -0
- package/lib/components/commons/components/combo-box/state-management/reducer/reduce-on-delete.js +23 -0
- package/lib/components/commons/components/combo-box/state-management/reducer/reduce-on-focus.js +22 -0
- package/lib/components/commons/components/combo-box/state-management/reducer/reduce-on-init.js +46 -0
- package/lib/components/commons/components/combo-box/state-management/reducer/reduce-on-keydown/index.js +15 -0
- package/lib/components/commons/components/combo-box/state-management/reducer/reduce-on-keydown/keyboard-key-codes.js +18 -0
- package/lib/components/commons/components/combo-box/state-management/reducer/reduce-on-keydown/on-arrow-down.js +37 -0
- package/lib/components/commons/components/combo-box/state-management/reducer/reduce-on-keydown/on-arrow-up.js +37 -0
- package/lib/components/commons/components/combo-box/state-management/reducer/reduce-on-keydown/on-end.js +28 -0
- package/lib/components/commons/components/combo-box/state-management/reducer/reduce-on-keydown/on-enter.js +23 -0
- package/lib/components/commons/components/combo-box/state-management/reducer/reduce-on-keydown/on-escape.js +22 -0
- package/lib/components/commons/components/combo-box/state-management/reducer/reduce-on-keydown/on-home.js +28 -0
- package/lib/components/commons/components/combo-box/state-management/reducer/reduce-on-keydown/on-tab.js +22 -0
- package/lib/components/commons/components/combo-box/state-management/reducer/reduce-on-keydown/reduce-on-keydown.js +59 -0
- package/lib/components/commons/components/combo-box/state-management/reducer/reduce-on-select.js +24 -0
- package/lib/components/commons/components/combo-box/state-management/reducer/reducer.js +63 -0
- package/lib/components/commons/components/create-lunatic-component/create-lunatic-component.js +75 -0
- package/lib/components/commons/components/create-lunatic-component/index.js +14 -0
- package/lib/components/commons/components/default-label-renderer.js +54 -0
- package/lib/components/commons/components/default-option-renderer.js +43 -0
- package/lib/components/commons/components/dragger/dragger.js +118 -0
- package/lib/components/commons/components/dragger/dragger.scss +8 -0
- package/lib/components/commons/components/dragger/index.js +15 -0
- package/lib/components/commons/components/errors/errors.js +55 -0
- package/lib/components/commons/components/errors/errors.scss +5 -0
- package/lib/components/commons/components/errors/index.js +15 -0
- package/lib/components/commons/components/fab/fab.js +56 -0
- package/lib/components/commons/components/fab/fab.scss +32 -0
- package/lib/components/commons/components/fab/index.js +15 -0
- package/lib/components/commons/components/field-container/field-container.js +48 -0
- package/lib/components/commons/components/field-container/field-container.scss +0 -0
- package/lib/components/commons/components/field-container/index.js +15 -0
- package/lib/components/commons/components/fieldset.js +26 -0
- package/lib/components/commons/components/fieldset.scss +5 -0
- package/lib/components/commons/components/html-table/index.js +55 -0
- package/lib/components/commons/components/html-table/table.js +38 -0
- package/lib/components/commons/components/html-table/tbody.js +38 -0
- package/lib/components/commons/components/html-table/td.js +50 -0
- package/lib/components/commons/components/html-table/th.js +48 -0
- package/lib/components/commons/components/html-table/thead.js +38 -0
- package/lib/components/commons/components/html-table/tr.js +40 -0
- package/lib/components/commons/components/is-network/index.js +15 -0
- package/lib/components/commons/components/is-network/is-network.js +70 -0
- package/lib/components/commons/components/is-network/use-online-status.js +55 -0
- package/lib/components/commons/components/label.js +35 -0
- package/lib/components/commons/components/lunatic-component.js +67 -0
- package/lib/components/commons/components/lunatic-fieldset-component.js +60 -0
- package/lib/components/commons/components/md-label/index.js +15 -0
- package/lib/components/commons/components/md-label/link.js +57 -0
- package/lib/components/commons/components/md-label/md-label.js +52 -0
- package/lib/components/commons/components/missing/index.js +15 -0
- package/lib/components/commons/components/missing/missing.js +90 -0
- package/lib/components/commons/components/missing/missing.scss +30 -0
- package/lib/components/commons/components/nothing-to-display.js +17 -0
- package/lib/components/commons/components/orchestrated-component.js +71 -0
- package/{src/components/tooltip → lib/components/commons/components/variable-status}/img/edited.png +0 -0
- package/{src/components/tooltip → lib/components/commons/components/variable-status}/img/forced.png +0 -0
- package/lib/components/commons/components/variable-status/img/index.js +23 -0
- package/lib/components/commons/components/variable-status/index.js +15 -0
- package/lib/components/commons/components/variable-status/variable-status.js +95 -0
- package/lib/components/commons/components/variable-status/variable-status.scss +39 -0
- package/lib/components/commons/create-customizable-field.js +37 -0
- package/lib/components/commons/create-row-orchestrator.js +60 -0
- package/lib/components/commons/icons/checkbox-checked.icon.js +41 -0
- package/lib/components/commons/icons/checkbox-unchecked.icon.js +41 -0
- package/lib/components/commons/icons/closed.icon.js +38 -0
- package/lib/components/commons/icons/cross.icon.js +38 -0
- package/lib/components/commons/icons/index.js +87 -0
- package/lib/components/commons/icons/load.icon.js +38 -0
- package/lib/components/commons/icons/lunatic-icon.js +25 -0
- package/lib/components/commons/icons/lunatic-icon.scss +3 -0
- package/lib/components/commons/icons/network.icon.js +38 -0
- package/lib/components/commons/icons/on-drag.icon.js +38 -0
- package/lib/components/commons/icons/opened.icon.js +38 -0
- package/lib/components/commons/icons/radio-checked.icon.js +41 -0
- package/lib/components/commons/icons/radio-unchecked.icon.js +41 -0
- package/lib/components/commons/index.js +162 -0
- package/lib/components/commons/prop-types/declarations.js +27 -0
- package/lib/components/commons/prop-types/index.js +47 -0
- package/lib/components/commons/prop-types/lines.js +17 -0
- package/lib/components/commons/prop-types/options.js +17 -0
- package/lib/components/commons/prop-types/response.js +17 -0
- package/lib/components/commons/prop-types/value-type.js +22 -0
- package/lib/components/commons/safety-label.js +34 -0
- package/lib/components/commons/use-document-add-event-listener.js +108 -0
- package/lib/components/commons/use-on-handle-change.js +22 -0
- package/lib/components/commons/use-options-keydown.js +29 -0
- package/lib/components/commons/use-previous.js +19 -0
- package/lib/components/components.js +188 -0
- package/lib/components/datepicker/datepicker.js +56 -0
- package/lib/components/datepicker/datepicker.scss +1 -0
- package/lib/components/datepicker/index.js +15 -0
- package/lib/components/datepicker/lunatic-datepicker.js +39 -0
- package/lib/components/declarations/declaration.js +26 -0
- package/lib/components/declarations/declarations-after-text.js +29 -0
- package/lib/components/declarations/declarations-before-text.js +29 -0
- package/lib/components/declarations/declarations-detachable.js +29 -0
- package/lib/components/declarations/declarations.js +61 -0
- package/lib/components/declarations/declarations.scss +36 -0
- package/lib/components/declarations/index.js +51 -0
- package/lib/components/dropdown/dropdown-simple/dropdown-simple.js +43 -0
- package/lib/components/dropdown/dropdown-simple/index.js +15 -0
- package/lib/components/dropdown/dropdown-simple/simple-label-renderer.js +53 -0
- package/lib/components/dropdown/dropdown-simple/simple-option-renderer.js +42 -0
- package/lib/components/dropdown/dropdown-writable/dropdown-writable.js +79 -0
- package/lib/components/dropdown/dropdown-writable/filter-tools/filter-options.js +47 -0
- package/lib/components/dropdown/dropdown-writable/filter-tools/letters-matching.js +40 -0
- package/lib/components/dropdown/dropdown-writable/filter-tools/match.js +27 -0
- package/lib/components/dropdown/dropdown-writable/filter-tools/prepare-prefix.js +17 -0
- package/lib/components/dropdown/dropdown-writable/index.js +15 -0
- package/lib/components/dropdown/dropdown-writable/writable-label-renderer.js +53 -0
- package/lib/components/dropdown/dropdown-writable/writable-option-renderer.js +170 -0
- package/lib/components/dropdown/dropdown.js +58 -0
- package/lib/components/dropdown/dropdown.scss +41 -0
- package/lib/components/dropdown/index.js +15 -0
- package/lib/components/dropdown/lunatic-dropdown.js +62 -0
- package/lib/components/filter-description/component.js +26 -0
- package/lib/components/filter-description/index.js +15 -0
- package/lib/components/index.js +32 -0
- package/lib/components/index.scss +136 -0
- package/lib/components/input/index.js +15 -0
- package/lib/components/input/input.js +61 -0
- package/lib/components/input/input.scss +32 -0
- package/lib/components/input/lunatic-input.js +43 -0
- package/lib/components/input-number/index.js +15 -0
- package/lib/components/input-number/input-number.js +61 -0
- package/lib/components/input-number/input-number.scss +7 -0
- package/lib/components/input-number/lunatic-input-number.js +37 -0
- package/lib/components/loop/block-for-loop/block-for-loop-ochestrator.js +16 -0
- package/lib/components/loop/block-for-loop/block-for-loop.js +171 -0
- package/lib/components/loop/block-for-loop/index.js +15 -0
- package/lib/components/loop/block-for-loop/row.js +84 -0
- package/lib/components/loop/commons/get-init-length.js +19 -0
- package/lib/components/loop/commons/handle-row-button.js +25 -0
- package/lib/components/loop/commons/index.js +23 -0
- package/lib/components/loop/commons/row-component.js +86 -0
- package/lib/components/loop/index.js +15 -0
- package/lib/components/loop/loop.js +94 -0
- package/lib/components/loop/roster-for-loop/body.js +69 -0
- package/lib/components/loop/roster-for-loop/header.js +42 -0
- package/lib/components/loop/roster-for-loop/index.js +15 -0
- package/lib/components/loop/roster-for-loop/roster-for-loop-orchestrator.js +16 -0
- package/lib/components/loop/roster-for-loop/roster-for-loop.js +153 -0
- package/lib/components/loop/roster-for-loop/roster-table.js +61 -0
- package/lib/components/loop/roster-for-loop/roster.scss +42 -0
- package/lib/components/loop/roster-for-loop/row.js +88 -0
- package/lib/components/modal-controls/close-or-skip.js +46 -0
- package/lib/components/modal-controls/index.js +15 -0
- package/lib/components/modal-controls/modal-container.js +24 -0
- package/lib/components/modal-controls/modal-controls.js +94 -0
- package/lib/components/modal-controls/modal-controls.scss +47 -0
- package/lib/components/pairwise/index.js +15 -0
- package/lib/components/pairwise/links/index.js +15 -0
- package/lib/components/pairwise/links/orchestrator.js +16 -0
- package/lib/components/pairwise/links/pairwise-links.js +75 -0
- package/lib/components/pairwise/links/row.js +95 -0
- package/lib/components/radio/index.js +15 -0
- package/lib/components/radio/lunatic-radio-group.js +45 -0
- package/lib/components/radio/radio-group.js +48 -0
- package/lib/components/radio/radio-option.js +94 -0
- package/lib/components/radio/radio.scss +66 -0
- package/lib/components/sequence/index.js +15 -0
- package/lib/components/sequence/sequence.js +41 -0
- package/lib/components/sequence/sequence.scss +10 -0
- package/lib/components/subsequence/index.js +15 -0
- package/lib/components/subsequence/subsequence.js +38 -0
- package/lib/components/suggester/check-store.js +149 -0
- package/lib/components/suggester/default-style.scss +125 -0
- package/lib/components/suggester/find-best-label/find-best-label.js +67 -0
- package/lib/components/suggester/find-best-label/index.js +15 -0
- package/lib/components/suggester/idb-suggester.js +95 -0
- package/lib/components/suggester/index.js +15 -0
- package/lib/components/suggester/lunatic-suggester.js +94 -0
- package/lib/components/suggester/searching/create-searching.js +88 -0
- package/lib/components/suggester/searching/index.js +15 -0
- package/lib/components/suggester/suggester.js +172 -0
- package/lib/components/suggester-loader-widget/index.js +15 -0
- package/lib/components/suggester-loader-widget/loader-row.js +150 -0
- package/lib/components/suggester-loader-widget/loader.js +180 -0
- package/lib/components/suggester-loader-widget/progress.js +45 -0
- package/lib/components/suggester-loader-widget/tools/action-tool.js +35 -0
- package/lib/components/suggester-loader-widget/tools/index.js +23 -0
- package/lib/components/suggester-loader-widget/tools/tools.js +20 -0
- package/lib/components/suggester-loader-widget/widget-container.js +48 -0
- package/lib/components/suggester-loader-widget/widget.js +170 -0
- package/lib/components/suggester-loader-widget/widget.scss +176 -0
- package/lib/components/switch/index.js +15 -0
- package/lib/components/switch/lunatic-switch.js +59 -0
- package/lib/components/switch/switch.js +92 -0
- package/lib/components/switch/switch.scss +47 -0
- package/lib/components/table/cell.js +113 -0
- package/lib/components/table/components/cell.js +113 -0
- package/lib/components/table/components/header.js +48 -0
- package/lib/components/table/components/row.js +47 -0
- package/lib/components/table/components/table.js +38 -0
- package/lib/components/table/components/table.scss +27 -0
- package/lib/components/table/index.js +15 -0
- package/lib/components/table/lunatic-table.js +97 -0
- package/lib/components/table/table-orchestrator.js +55 -0
- package/lib/components/textarea/index.js +15 -0
- package/lib/components/textarea/lunatic-textarea.js +52 -0
- package/lib/components/textarea/textarea.js +54 -0
- package/lib/components/textarea/textarea.scss +8 -0
- package/lib/constants/component-types.js +8 -0
- package/lib/constants/declarations.js +26 -0
- package/lib/constants/event-types.js +28 -0
- package/lib/constants/index.js +70 -0
- package/lib/constants/supported-preferences.js +18 -0
- package/lib/constants/value-types.js +16 -0
- package/lib/constants/variable-types.js +12 -0
- package/lib/i18n/build-dictionary.js +56 -0
- package/lib/i18n/dictionary.js +26 -0
- package/lib/i18n/index.js +19 -0
- package/lib/index.js +21 -4300
- package/lib/stories/Introduction.stories.mdx +114 -0
- package/lib/stories/checkboxBoolean/checkboxBoolean.stories.js +35 -0
- package/lib/stories/checkboxBoolean/source.json +36 -0
- package/lib/stories/checkboxOne/checkboxOne.stories.js +35 -0
- package/lib/stories/checkboxOne/source.json +36 -0
- package/lib/stories/custom-mui/checkbox-boolean-mui.js +39 -0
- package/lib/stories/custom-mui/checkbox-group-mui.js +80 -0
- package/lib/stories/custom-mui/checkbox-one-mui.js +17 -0
- package/lib/stories/custom-mui/index.js +127 -0
- package/lib/stories/custom-mui/input-mui.js +61 -0
- package/lib/stories/custom-mui/input-number-mui.js +47 -0
- package/lib/stories/custom-mui/radio-mui.js +75 -0
- package/lib/stories/custom-mui/suggester-mui/index.js +15 -0
- package/lib/stories/custom-mui/suggester-mui/suggester-mui.js +328 -0
- package/lib/stories/custom-mui/switch-mui.js +51 -0
- package/lib/stories/custom-mui/table-mui.js +33 -0
- package/lib/stories/custom-mui/tbody-mui.js +27 -0
- package/lib/stories/custom-mui/td-mui.js +29 -0
- package/lib/stories/custom-mui/textarea-mui.js +51 -0
- package/lib/stories/custom-mui/th-mui.js +28 -0
- package/lib/stories/custom-mui/thead-mui.js +27 -0
- package/lib/stories/custom-mui/tr-mui.js +38 -0
- package/lib/stories/date-picker/data.json +3 -0
- package/lib/stories/date-picker/datepicker.stories.js +40 -0
- package/lib/stories/date-picker/source.json +91 -0
- package/lib/stories/dropdown/data.json +16 -0
- package/lib/stories/dropdown/dropdown.stories.js +41 -0
- package/lib/stories/dropdown/source.json +122 -0
- package/lib/stories/filter-description/filter-description.stories.js +58 -0
- package/lib/stories/filter-description/source-options.json +81 -0
- package/lib/stories/filter-description/source.json +11 -0
- package/lib/stories/input/data.json +1 -0
- package/lib/stories/input/input.stories.js +38 -0
- package/lib/stories/input/source.json +28 -0
- package/lib/stories/input-number/input-number.stories.js +43 -0
- package/lib/stories/input-number/source-euros.json +38 -0
- package/lib/stories/input-number/source.json +37 -0
- package/lib/stories/pairwise/data.json +13 -0
- package/lib/stories/pairwise/links.json +207 -0
- package/lib/stories/pairwise/pairwise-links.stories.js +39 -0
- package/lib/stories/paste-questionnaire/source.json +6290 -0
- package/lib/stories/paste-questionnaire/test.stories.js +91 -0
- package/lib/stories/questionnaires/logement/data.json +2691 -0
- package/lib/stories/questionnaires/logement/logement.stories.js +86 -0
- package/lib/stories/questionnaires/logement/source-sequence.json +34181 -0
- package/lib/stories/questionnaires/logement/source-sum.json +34612 -0
- package/lib/stories/questionnaires/logement/source.json +34191 -0
- package/lib/stories/questionnaires/simpsons/simpsons.stories.js +71 -0
- package/lib/stories/questionnaires/simpsons/source.json +6290 -0
- package/lib/stories/questionnaires-test/V2_DeclarationsSimples.json +848 -0
- package/lib/stories/questionnaires-test/V2_MinMaxSum_Boucles.json +509 -0
- package/lib/stories/questionnaires-test/V2_QuestSimple_Boucles.json +4091 -0
- package/lib/stories/questionnaires-test/V2_TCMRallyeGames.json +2892 -0
- package/lib/stories/questionnaires-test/controls/V2_ControlesNonNum_horsBoucle_PasPageFin.json +666 -0
- package/lib/stories/questionnaires-test/controls/V2_ControlesNum_horsBoucle_PasPageFin.json +1957 -0
- package/lib/stories/questionnaires-test/controls/V2_Controles_BouclesLiees2_PasPageFin.json +709 -0
- package/lib/stories/questionnaires-test/controls/V2_Controles_BouclesLiees_PasPageFin.json +533 -0
- package/lib/stories/questionnaires-test/controls/boucles-n.json +202 -0
- package/lib/stories/questionnaires-test/controls/controls.stories.js +108 -0
- package/lib/stories/questionnaires-test/test-dylan.json +558 -0
- package/lib/stories/questionnaires-test/test.stories.js +104 -0
- package/lib/stories/radio/radio.stories.js +35 -0
- package/lib/stories/radio/source.json +36 -0
- package/lib/stories/roster-for-loop/roster-for-loop.stories.js +35 -0
- package/lib/stories/roster-for-loop/source.json +114 -0
- package/lib/stories/suggester/source.json +234 -0
- package/lib/stories/suggester/suggester-workers.stories.js +242 -0
- package/lib/stories/suggester/suggester.stories.js +59 -0
- package/{src/stories/checkbox-one → lib/stories/switch}/README.md +31 -31
- package/lib/stories/switch/SwitchMaterialUI.js +51 -0
- package/{src/stories/checkbox-boolean/data.json → lib/stories/switch/data-forced.json} +48 -48
- package/lib/stories/switch/data.json +80 -0
- package/lib/stories/switch/switch.js +108 -0
- package/lib/stories/table/data-roster.json +1 -0
- package/lib/stories/table/data.json +1 -0
- package/{src/stories/table/data-roster.json → lib/stories/table/source-roster.json} +504 -461
- package/{src/stories/table/data-default.json → lib/stories/table/source.json} +19 -19
- package/lib/stories/table/table-dynamique.json +67 -0
- package/lib/stories/table/table.stories.js +73 -0
- package/lib/stories/utils/custom-lunatic.scss +28 -0
- package/lib/stories/utils/default-arg-types.js +23 -0
- package/lib/stories/utils/options.js +32 -0
- package/lib/stories/utils/orchestrator.js +188 -0
- package/lib/stories/utils/waiting/index.js +15 -0
- package/lib/stories/utils/waiting/preloader.svg +1 -0
- package/lib/stories/utils/waiting/waiting.js +40 -0
- package/lib/stories/utils/waiting/waiting.scss +21 -0
- package/lib/tests/sample.spec.js +7 -0
- package/lib/use-lunatic/actions.js +102 -0
- package/lib/use-lunatic/commons/calculated-variables.js +124 -0
- package/lib/use-lunatic/commons/check-loops.js +111 -0
- package/lib/use-lunatic/commons/compose.js +28 -0
- package/lib/use-lunatic/commons/create-map-pages.js +108 -0
- package/lib/use-lunatic/commons/execute-condition-filter.js +34 -0
- package/lib/use-lunatic/commons/execute-expression/create-execute-expression.js +308 -0
- package/lib/use-lunatic/commons/execute-expression/create-memoizer.js +78 -0
- package/lib/use-lunatic/commons/execute-expression/create-refresh-calculated.js +160 -0
- package/lib/use-lunatic/commons/execute-expression/execute-expression.js +118 -0
- package/lib/use-lunatic/commons/execute-expression/get-expressions-variables.js +51 -0
- package/lib/use-lunatic/commons/execute-expression/get-safety-expression.js +37 -0
- package/lib/use-lunatic/commons/execute-expression/index.js +15 -0
- package/lib/use-lunatic/commons/fill-components/fill-component-expressions.js +149 -0
- package/lib/use-lunatic/commons/fill-components/fill-component-value.js +26 -0
- package/lib/use-lunatic/commons/fill-components/fill-components.js +47 -0
- package/lib/use-lunatic/commons/fill-components/fill-errors.js +31 -0
- package/lib/use-lunatic/commons/fill-components/fill-from-state.js +26 -0
- package/lib/use-lunatic/commons/fill-components/fill-management.js +27 -0
- package/lib/use-lunatic/commons/fill-components/fill-missing-response.js +37 -0
- package/lib/use-lunatic/commons/fill-components/fill-pagination.js +23 -0
- package/lib/use-lunatic/commons/fill-components/index.js +15 -0
- package/lib/use-lunatic/commons/get-compatible-vtl-expression.js +32 -0
- package/lib/use-lunatic/commons/get-component-value/get-component-value.js +217 -0
- package/lib/use-lunatic/commons/get-component-value/index.js +15 -0
- package/lib/use-lunatic/commons/get-components-from-state.js +44 -0
- package/lib/use-lunatic/commons/get-data.js +90 -0
- package/lib/use-lunatic/commons/get-errors-without-empty-value.js +31 -0
- package/lib/use-lunatic/commons/index.js +123 -0
- package/lib/use-lunatic/commons/is-First-last-page.js +20 -0
- package/lib/use-lunatic/commons/is-paginated-loop.js +15 -0
- package/lib/use-lunatic/commons/load-suggesters.js +199 -0
- package/lib/use-lunatic/commons/page-tag.js +83 -0
- package/lib/use-lunatic/commons/use-components-from-state.js +49 -0
- package/lib/use-lunatic/index.js +15 -0
- package/lib/use-lunatic/initial-state.js +44 -0
- package/lib/use-lunatic/reducer/commons/index.js +41 -0
- package/lib/use-lunatic/reducer/commons/is-empty-on-empty-page.js +49 -0
- package/lib/use-lunatic/reducer/commons/resize-array-variable.js +48 -0
- package/lib/use-lunatic/reducer/commons/validate-condition-filter.js +41 -0
- package/lib/use-lunatic/reducer/index.js +15 -0
- package/lib/use-lunatic/reducer/reduce-go-next-page.js +218 -0
- package/lib/use-lunatic/reducer/reduce-go-previous-page.js +165 -0
- package/lib/use-lunatic/reducer/reduce-go-to-page.js +60 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/index.js +15 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-cleaning.js +77 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-handle-change.js +142 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-links-variable.js +53 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-missing.js +90 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-resizing.js +118 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-variables-array.js +50 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-variables-simple.js +29 -0
- package/lib/use-lunatic/reducer/reduce-on-init.js +260 -0
- package/lib/use-lunatic/reducer/reduce-on-set-waiting.js +23 -0
- package/lib/use-lunatic/reducer/reducer.js +58 -0
- package/lib/use-lunatic/reducer/validate-controls/create-controls-reducer.js +69 -0
- package/lib/use-lunatic/reducer/validate-controls/create-modal-controls-reducer.js +100 -0
- package/lib/use-lunatic/reducer/validate-controls/index.js +23 -0
- package/lib/use-lunatic/reducer/validate-controls/validation-utils.js +73 -0
- package/lib/use-lunatic/use-lunatic.js +215 -0
- package/lib/utils/constants/features.js +12 -0
- package/lib/utils/constants/index.js +70 -0
- package/lib/utils/constants/links.js +10 -0
- package/lib/utils/constants/missing.js +10 -0
- package/lib/utils/constants/variable-status.js +16 -0
- package/lib/utils/constants/variable-types.js +8 -0
- package/lib/utils/idb-tools/clear-store.js +52 -0
- package/lib/utils/idb-tools/create-db-opener.js +60 -0
- package/lib/utils/idb-tools/create-open-db.js +35 -0
- package/lib/utils/idb-tools/get-entity.js +25 -0
- package/lib/utils/idb-tools/get-idb.js +15 -0
- package/lib/utils/idb-tools/idb-bulk-insert.js +157 -0
- package/lib/utils/idb-tools/index.js +75 -0
- package/lib/utils/idb-tools/insert-entity.js +25 -0
- package/lib/utils/idb-tools/open-db.js +29 -0
- package/lib/utils/idb-tools/open-or-create-db.js +49 -0
- package/lib/utils/is-element.js +12 -0
- package/lib/utils/store-tools/auto-load.js +209 -0
- package/lib/utils/store-tools/clear-store-data.js +46 -0
- package/lib/utils/store-tools/clear-store-info.js +46 -0
- package/lib/utils/store-tools/constantes.js +31 -0
- package/lib/utils/store-tools/create/create.js +70 -0
- package/lib/utils/store-tools/create/index.js +23 -0
- package/lib/utils/store-tools/create/update-store-info.js +33 -0
- package/lib/utils/store-tools/get-store-count.js +29 -0
- package/lib/utils/store-tools/index.js +66 -0
- package/lib/utils/store-tools/open-or-create-store.js +60 -0
- package/lib/utils/store-tools/use-store-index.js +82 -0
- package/lib/utils/suggester-workers/append-to-index/append.js +96 -0
- package/lib/utils/suggester-workers/append-to-index/append.worker.js +31 -0
- package/lib/utils/suggester-workers/append-to-index/create-append-task.js +66 -0
- package/lib/utils/suggester-workers/append-to-index/index.js +23 -0
- package/lib/utils/suggester-workers/append-to-index/prepare-entities.js +114 -0
- package/lib/utils/suggester-workers/append-to-index/store-messages.js +48 -0
- package/lib/utils/suggester-workers/commons-tokenizer/create-entity-tokenizer.js +70 -0
- package/lib/utils/suggester-workers/commons-tokenizer/create-fields-tokenizer.js +103 -0
- package/lib/utils/suggester-workers/commons-tokenizer/create-filter-stop-words.js +47 -0
- package/lib/utils/suggester-workers/commons-tokenizer/filters/compose-filters.js +24 -0
- package/lib/utils/suggester-workers/commons-tokenizer/filters/create-filter-stop-words.js +47 -0
- package/lib/utils/suggester-workers/commons-tokenizer/filters/create-filter-stop-words.spec.js +16 -0
- package/lib/utils/suggester-workers/commons-tokenizer/filters/filter-accents.js +24 -0
- package/lib/utils/suggester-workers/commons-tokenizer/filters/filter-accents.spec.js +18 -0
- package/lib/utils/suggester-workers/commons-tokenizer/filters/filter-double.js +34 -0
- package/lib/utils/suggester-workers/commons-tokenizer/filters/filter-double.spec.js +25 -0
- package/lib/utils/suggester-workers/commons-tokenizer/filters/filter-length.js +17 -0
- package/lib/utils/suggester-workers/commons-tokenizer/filters/filter-length.spec.js +25 -0
- package/lib/utils/suggester-workers/commons-tokenizer/filters/filter-stemmer.js +29 -0
- package/lib/utils/suggester-workers/commons-tokenizer/filters/filter-stemmer.spec.js +18 -0
- package/lib/utils/suggester-workers/commons-tokenizer/filters/filter-synonyms.js +71 -0
- package/lib/utils/suggester-workers/commons-tokenizer/filters/filter-synonyms.spec.js +15 -0
- package/lib/utils/suggester-workers/commons-tokenizer/filters/filter-to-lower.js +19 -0
- package/lib/utils/suggester-workers/commons-tokenizer/filters/filter-to-lower.spec.js +16 -0
- package/lib/utils/suggester-workers/commons-tokenizer/filters/index.js +23 -0
- package/lib/utils/suggester-workers/commons-tokenizer/filters/stop-words.js +9 -0
- package/lib/utils/suggester-workers/commons-tokenizer/get-regexp-from-pattern.js +17 -0
- package/lib/utils/suggester-workers/commons-tokenizer/get-stemmer.js +31 -0
- package/lib/utils/suggester-workers/commons-tokenizer/index.js +79 -0
- package/lib/utils/suggester-workers/commons-tokenizer/prepare-string-indexation.js +24 -0
- package/lib/utils/suggester-workers/commons-tokenizer/soft-tokenizer.js +15 -0
- package/lib/utils/suggester-workers/create-worker.js +64 -0
- package/lib/utils/suggester-workers/find-best-label/find-best-label.js +81 -0
- package/lib/utils/suggester-workers/find-best-label/find-best-label.worker.js +67 -0
- package/lib/utils/suggester-workers/find-best-label/index.js +1 -0
- package/lib/utils/suggester-workers/find-best-label/tokenize.js +62 -0
- package/lib/utils/suggester-workers/find-best-label/tokenize.spec.js +26 -0
- package/lib/utils/suggester-workers/searching/compute-score.js +63 -0
- package/lib/utils/suggester-workers/searching/get-db.js +64 -0
- package/lib/utils/suggester-workers/searching/index.js +15 -0
- package/lib/utils/suggester-workers/searching/order/create-alphanumeric-orderer.js +33 -0
- package/lib/utils/suggester-workers/searching/order/index.js +33 -0
- package/lib/utils/suggester-workers/searching/query-parser/index.js +23 -0
- package/lib/utils/suggester-workers/searching/query-parser/query-parser-soft.js +15 -0
- package/lib/utils/suggester-workers/searching/query-parser/query-parser-soft.spec.js +28 -0
- package/lib/utils/suggester-workers/searching/query-parser/query-parser-tokenized.js +51 -0
- package/lib/utils/suggester-workers/searching/resolve-query-parser.js +73 -0
- package/lib/utils/suggester-workers/searching/search-in-index.js +25 -0
- package/lib/utils/suggester-workers/searching/searching.js +170 -0
- package/lib/utils/suggester-workers/searching/searching.worker.js +23 -0
- package/lib/utils/vtl/dataset-builder.js +28 -0
- package/lib/utils/vtl/index.js +15 -0
- package/package.json +161 -139
- package/lib/index.js.map +0 -1
- package/src/components/breadcrumb/breadcrumb.scss +0 -22
- package/src/components/breadcrumb/component.js +0 -29
- package/src/components/breadcrumb/index.js +0 -1
- package/src/components/button/button.scss +0 -26
- package/src/components/button/component.js +0 -25
- package/src/components/button/index.js +0 -1
- package/src/components/checkbox/boolean.js +0 -147
- package/src/components/checkbox/checkbox.scss +0 -43
- package/src/components/checkbox/group.js +0 -183
- package/src/components/checkbox/index.js +0 -3
- package/src/components/checkbox/one.js +0 -10
- package/src/components/components.js +0 -16
- package/src/components/datepicker/component.js +0 -10
- package/src/components/datepicker/datepicker.scss +0 -16
- package/src/components/datepicker/index.js +0 -1
- package/src/components/declarations/component.js +0 -38
- package/src/components/declarations/declarations.scss +0 -34
- package/src/components/declarations/index.js +0 -1
- package/src/components/declarations/wrappers/index.js +0 -3
- package/src/components/declarations/wrappers/input-declarations-wrapper.js +0 -168
- package/src/components/declarations/wrappers/list-declarations-wrapper.js +0 -190
- package/src/components/declarations/wrappers/simple-declarations-wrapper.js +0 -54
- package/src/components/dropdown/commons/actions.js +0 -56
- package/src/components/dropdown/commons/children-to-option.js +0 -9
- package/src/components/dropdown/commons/cleaner-callbacks.js +0 -58
- package/src/components/dropdown/commons/components/closed.icon.js +0 -24
- package/src/components/dropdown/commons/components/dropdown-container.js +0 -29
- package/src/components/dropdown/commons/components/dropdown-field.js +0 -46
- package/src/components/dropdown/commons/components/dropdown.js +0 -182
- package/src/components/dropdown/commons/components/label.js +0 -28
- package/src/components/dropdown/commons/components/opened.icon.js +0 -24
- package/src/components/dropdown/commons/components/panel.js +0 -78
- package/src/components/dropdown/commons/event-callbacks/index.js +0 -5
- package/src/components/dropdown/commons/event-callbacks/on-keydown-callback.js +0 -29
- package/src/components/dropdown/commons/event-callbacks/on-mousedown-callback.js +0 -11
- package/src/components/dropdown/commons/reducer.js +0 -149
- package/src/components/dropdown/commons/tools/index.js +0 -17
- package/src/components/dropdown/component.js +0 -117
- package/src/components/dropdown/dropdown-edit/cross.icon.js +0 -20
- package/src/components/dropdown/dropdown-edit/dropdown-edit.js +0 -185
- package/src/components/dropdown/dropdown-edit/icone.js +0 -33
- package/src/components/dropdown/dropdown-edit/index.js +0 -11
- package/src/components/dropdown/dropdown-edit/option.js +0 -62
- package/src/components/dropdown/dropdown-edit/prefix-tools.js +0 -51
- package/src/components/dropdown/dropdown-simple/dropdown.js +0 -155
- package/src/components/dropdown/dropdown-simple/index.js +0 -20
- package/src/components/dropdown/dropdown-simple/option.js +0 -15
- package/src/components/dropdown/dropdown.scss +0 -201
- package/src/components/dropdown/index.js +0 -1
- package/src/components/filter-description/component.js +0 -41
- package/src/components/filter-description/index.js +0 -1
- package/src/components/index.js +0 -4
- package/src/components/index.scss +0 -76
- package/src/components/input/index.js +0 -2
- package/src/components/input/input-number.js +0 -232
- package/src/components/input/input.js +0 -10
- package/src/components/input/input.scss +0 -27
- package/src/components/loop/build-components.js +0 -33
- package/src/components/loop/component.js +0 -94
- package/src/components/loop/index.js +0 -1
- package/src/components/loop/loop.scss +0 -17
- package/src/components/loop/wrapper.js +0 -11
- package/src/components/loop-constructor/block/block.scss +0 -10
- package/src/components/loop-constructor/block/component.js +0 -8
- package/src/components/loop-constructor/block/index.js +0 -1
- package/src/components/loop-constructor/index.js +0 -1
- package/src/components/loop-constructor/roster/component.js +0 -7
- package/src/components/loop-constructor/roster/index.js +0 -1
- package/src/components/loop-constructor/wrapper/body-component.js +0 -118
- package/src/components/loop-constructor/wrapper/build-components.js +0 -33
- package/src/components/loop-constructor/wrapper/component.js +0 -152
- package/src/components/loop-constructor/wrapper/index.js +0 -1
- package/src/components/progress-bar/component.js +0 -28
- package/src/components/progress-bar/index.js +0 -1
- package/src/components/progress-bar/progress-bar.scss +0 -54
- package/src/components/radio/component.js +0 -8
- package/src/components/radio/index.js +0 -1
- package/src/components/radio/radio.scss +0 -24
- package/src/components/sequence/component.js +0 -41
- package/src/components/sequence/index.js +0 -1
- package/src/components/sequence/sequence.scss +0 -15
- package/src/components/subsequence/component.js +0 -48
- package/src/components/subsequence/index.js +0 -1
- package/src/components/subsequence/subsequence.scss +0 -15
- package/src/components/table/index.js +0 -1
- package/src/components/table/table.js +0 -160
- package/src/components/table/table.scss +0 -23
- package/src/components/textarea/component.js +0 -10
- package/src/components/textarea/index.js +0 -1
- package/src/components/textarea/textarea.scss +0 -16
- package/src/components/tooltip/img/collected.png +0 -0
- package/src/components/tooltip/img/index.js +0 -5
- package/src/components/tooltip/index.js +0 -1
- package/src/components/tooltip/response.js +0 -51
- package/src/components/tooltip/tooltip.scss +0 -35
- package/src/constants/component-types.js +0 -1
- package/src/constants/declarations.js +0 -14
- package/src/constants/index.js +0 -4
- package/src/constants/supported-preferences.js +0 -10
- package/src/constants/value-types.js +0 -5
- package/src/constants/variable-types.js +0 -4
- package/src/stories/breadcrumb/README.md +0 -14
- package/src/stories/breadcrumb/breadcrumb.stories.js +0 -33
- package/src/stories/button/README.md +0 -14
- package/src/stories/button/button.stories.js +0 -63
- package/src/stories/checkbox-boolean/README.md +0 -27
- package/src/stories/checkbox-boolean/checkbox-boolean.stories.js +0 -30
- package/src/stories/checkbox-group/README.md +0 -29
- package/src/stories/checkbox-group/checkbox-group.stories.js +0 -81
- package/src/stories/checkbox-group/data-vtl.json +0 -89
- package/src/stories/checkbox-group/data.json +0 -89
- package/src/stories/checkbox-one/checkbox-one.stories.js +0 -77
- package/src/stories/checkbox-one/data-vtl.json +0 -33
- package/src/stories/checkbox-one/data.json +0 -33
- package/src/stories/datepicker/README.md +0 -31
- package/src/stories/datepicker/data.json +0 -28
- package/src/stories/datepicker/datepicker.stories.js +0 -65
- package/src/stories/declarations/README.md +0 -19
- package/src/stories/declarations/declarations.stories.js +0 -112
- package/src/stories/dropdown/README.md +0 -44
- package/src/stories/dropdown/data-naf.json +0 -6963
- package/src/stories/dropdown/data-props.json +0 -81
- package/src/stories/dropdown/data.json +0 -78
- package/src/stories/dropdown/dropdown.stories.js +0 -65
- package/src/stories/filter-description/README.md +0 -15
- package/src/stories/filter-description/filter-description.stories.js +0 -70
- package/src/stories/input/README.md +0 -33
- package/src/stories/input/data.json +0 -28
- package/src/stories/input/input.stories.js +0 -67
- package/src/stories/input-number/README.md +0 -37
- package/src/stories/input-number/data.json +0 -30
- package/src/stories/input-number/input-number.stories.js +0 -75
- package/src/stories/loop/README.md +0 -25
- package/src/stories/loop/loop.stories.js +0 -80
- package/src/stories/loop/with-loop/data-loop-deeper.json +0 -298
- package/src/stories/loop/with-loop/data-loop.json +0 -211
- package/src/stories/loop/with-loop/data-vqs.json +0 -1384
- package/src/stories/loop/with-loop/index.js +0 -3
- package/src/stories/loop/with-roster/data-loop-deeper.json +0 -298
- package/src/stories/loop/with-roster/data-loop.json +0 -213
- package/src/stories/loop/with-roster/data-vqs.json +0 -1383
- package/src/stories/loop/with-roster/index.js +0 -3
- package/src/stories/loop-constructor/README.md +0 -27
- package/src/stories/loop-constructor/data-loop.json +0 -66
- package/src/stories/loop-constructor/data-roster.json +0 -68
- package/src/stories/loop-constructor/loop-constructor.stories.js +0 -42
- package/src/stories/progress-bar/README.md +0 -13
- package/src/stories/progress-bar/progress-bar.stories.js +0 -24
- package/src/stories/questionnaire/fat.json +0 -6558
- package/src/stories/questionnaire/questionnaire.stories.js +0 -25
- package/src/stories/radio/README.md +0 -31
- package/src/stories/radio/data-vtl.json +0 -32
- package/src/stories/radio/data.json +0 -32
- package/src/stories/radio/radio.stories.js +0 -81
- package/src/stories/sequence/README.md +0 -18
- package/src/stories/sequence/sequence.stories.js +0 -58
- package/src/stories/subsequence/README.md +0 -18
- package/src/stories/subsequence/subsequence.stories.js +0 -58
- package/src/stories/table/README.md +0 -29
- package/src/stories/table/data-one-axis-one-measure.json +0 -124
- package/src/stories/table/data-one-axis-two-measures.json +0 -193
- package/src/stories/table/data-one-hierarchical-axis.json +0 -204
- package/src/stories/table/data-two-axis-one-measure.json +0 -492
- package/src/stories/table/table.stories.js +0 -77
- package/src/stories/textarea/README.md +0 -33
- package/src/stories/textarea/data-forced.json +0 -28
- package/src/stories/textarea/data.json +0 -28
- package/src/stories/textarea/textarea.stories.js +0 -90
- package/src/stories/tooltip-response/README.md +0 -14
- package/src/stories/tooltip-response/tooltip.stories.js +0 -43
- package/src/stories/utils/custom-lunatic.scss +0 -595
- package/src/stories/utils/img/arrow.png +0 -0
- package/src/stories/utils/img/check_box.svg +0 -1
- package/src/stories/utils/img/check_box_outline.svg +0 -1
- package/src/stories/utils/img/lunatic-logo.png +0 -0
- package/src/stories/utils/img/menu-down.svg +0 -1
- package/src/stories/utils/img/menu-up.svg +0 -1
- package/src/stories/utils/img/radio_button_checked.svg +0 -1
- package/src/stories/utils/img/radio_button_unchecked.svg +0 -1
- package/src/stories/utils/options.js +0 -21
- package/src/stories/utils/orchestrator.js +0 -53
- 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 -175
- package/src/tests/components/input.spec.js +0 -18
- 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/checkbox/group.spec.js +0 -72
- package/src/tests/utils/lib/decorator/title-decorator.spec.js +0 -12
- 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 -60
- package/src/tests/utils/lib/loops/shared.spec.js +0 -77
- 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 -86
- package/src/tests/utils/to-expose/handler/questionnaire.json +0 -154
- package/src/tests/utils/to-expose/handler/results/index.js +0 -6
- package/src/tests/utils/to-expose/handler/results/res-double.json +0 -157
- package/src/tests/utils/to-expose/handler/results/res-input-collected.json +0 -154
- package/src/tests/utils/to-expose/handler/results/res-input-edited.json +0 -157
- package/src/tests/utils/to-expose/handler/results/res-loop.json +0 -157
- package/src/tests/utils/to-expose/handler/results/res-matrix.json +0 -157
- package/src/tests/utils/to-expose/handler/results/res-responses.json +0 -157
- 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 -129
- package/src/tests/utils/to-expose/init-questionnaire/result.json +0 -162
- package/src/tests/utils/to-expose/interpret.spec.js +0 -42
- 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/lib/alphabet.js +0 -1
- package/src/utils/lib/checkbox/group.js +0 -21
- package/src/utils/lib/checkbox/index.js +0 -1
- package/src/utils/lib/decorator/index.js +0 -1
- package/src/utils/lib/decorator/title-decorator.js +0 -16
- package/src/utils/lib/index.js +0 -12
- package/src/utils/lib/label-position.js +0 -12
- package/src/utils/lib/loops/bindings.js +0 -47
- package/src/utils/lib/loops/index.js +0 -2
- package/src/utils/lib/loops/shared.js +0 -43
- package/src/utils/lib/memo-check.js +0 -24
- package/src/utils/lib/options-positioning.js +0 -9
- package/src/utils/lib/prop-types/declarations.js +0 -22
- package/src/utils/lib/prop-types/index.js +0 -5
- package/src/utils/lib/prop-types/lines.js +0 -6
- package/src/utils/lib/prop-types/options.js +0 -8
- package/src/utils/lib/prop-types/response.js +0 -6
- package/src/utils/lib/prop-types/value-type.js +0 -9
- package/src/utils/lib/responses.js +0 -9
- package/src/utils/lib/style.js +0 -10
- package/src/utils/lib/table/index.js +0 -1
- package/src/utils/lib/table/roster.js +0 -18
- package/src/utils/lib/tooltip/build-response.js +0 -41
- package/src/utils/lib/tooltip/content.js +0 -52
- package/src/utils/lib/tooltip/index.js +0 -6
- package/src/utils/to-expose/handler.js +0 -99
- package/src/utils/to-expose/hook.js +0 -65
- package/src/utils/to-expose/index.js +0 -11
- package/src/utils/to-expose/init-questionnaire.js +0 -114
- package/src/utils/to-expose/interpret.js +0 -53
- package/src/utils/to-expose/state.js +0 -58
package/lib/index.js
CHANGED
|
@@ -1,4311 +1,32 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var vtl2_1Engine = require('@inseefr/vtl-2.1-engine');
|
|
6
|
-
var camelCase = require('lodash.camelcase');
|
|
7
|
-
var isEqual = require('lodash.isequal');
|
|
8
|
-
var debounce = require('lodash.debounce');
|
|
9
|
-
var removeAccents = require('remove-accents');
|
|
10
|
-
|
|
11
|
-
function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
|
|
12
|
-
|
|
13
|
-
var React__default = /*#__PURE__*/_interopDefaultLegacy(React);
|
|
14
|
-
var PropTypes__default = /*#__PURE__*/_interopDefaultLegacy(PropTypes);
|
|
15
|
-
var camelCase__default = /*#__PURE__*/_interopDefaultLegacy(camelCase);
|
|
16
|
-
var isEqual__default = /*#__PURE__*/_interopDefaultLegacy(isEqual);
|
|
17
|
-
var debounce__default = /*#__PURE__*/_interopDefaultLegacy(debounce);
|
|
18
|
-
var removeAccents__default = /*#__PURE__*/_interopDefaultLegacy(removeAccents);
|
|
19
|
-
|
|
20
|
-
var lunatic = /*#__PURE__*/Object.freeze({
|
|
21
|
-
__proto__: null,
|
|
22
|
-
get Breadcrumb () { return Breadcrumb; },
|
|
23
|
-
get Button () { return Button; },
|
|
24
|
-
get Datepicker () { return component; },
|
|
25
|
-
get Declarations () { return Declarations; },
|
|
26
|
-
get Dropdown () { return component$1; },
|
|
27
|
-
get FilterDescription () { return FilterDescription; },
|
|
28
|
-
get ProgressBar () { return ProgressBar; },
|
|
29
|
-
get Radio () { return component$2; },
|
|
30
|
-
get Loop () { return LoopWrapper; },
|
|
31
|
-
get Sequence () { return component$4; },
|
|
32
|
-
get Subsequence () { return component$5; },
|
|
33
|
-
get Textarea () { return component$6; },
|
|
34
|
-
get TooltipResponse () { return TooltipResponse; },
|
|
35
|
-
get CheckboxGroup () { return group; },
|
|
36
|
-
get CheckboxBoolean () { return boolean; },
|
|
37
|
-
get CheckboxOne () { return one; },
|
|
38
|
-
get Input () { return input; },
|
|
39
|
-
get InputNumber () { return inputNumber; },
|
|
40
|
-
get RosterForLoop () { return component$3; }
|
|
41
|
-
});
|
|
42
|
-
|
|
43
|
-
// Declaration position
|
|
44
|
-
var BEFORE_QUESTION_TEXT = 'BEFORE_QUESTION_TEXT';
|
|
45
|
-
var AFTER_QUESTION_TEXT = 'AFTER_QUESTION_TEXT';
|
|
46
|
-
var DETACHABLE = 'DETACHABLE'; // Declaration types
|
|
47
|
-
|
|
48
|
-
var INSTRUCTION = 'INSTRUCTION';
|
|
49
|
-
var COMMENT = 'COMMENT';
|
|
50
|
-
var HELP = 'HELP';
|
|
51
|
-
var WARNING = 'WARNING';
|
|
52
|
-
var MESSAGE_FILTER = 'MESSAGE_FILTER';
|
|
53
|
-
var STATEMENT = 'STATEMENT';
|
|
54
|
-
|
|
55
|
-
var PREVIOUS = 'PREVIOUS';
|
|
56
|
-
var COLLECTED = 'COLLECTED';
|
|
57
|
-
var FORCED = 'FORCED';
|
|
58
|
-
var EDITED = 'EDITED';
|
|
59
|
-
var INPUTED = 'INPUTED';
|
|
60
|
-
|
|
61
|
-
var EXTERNAL = 'EXTERNAL';
|
|
62
|
-
var CALCULATED = 'CALCULATED'; // Already define in value-types
|
|
63
|
-
//export const COLLECTED = 'COLLECTED';
|
|
64
|
-
|
|
65
|
-
var declarations = PropTypes__default['default'].arrayOf(PropTypes__default['default'].shape({
|
|
66
|
-
id: PropTypes__default['default'].string.isRequired,
|
|
67
|
-
declarationType: PropTypes__default['default'].oneOf([INSTRUCTION, COMMENT, HELP, WARNING, MESSAGE_FILTER, STATEMENT]),
|
|
68
|
-
position: PropTypes__default['default'].oneOf([BEFORE_QUESTION_TEXT, AFTER_QUESTION_TEXT, DETACHABLE]),
|
|
69
|
-
label: PropTypes__default['default'].string.isRequired
|
|
70
|
-
})).isRequired;
|
|
71
|
-
|
|
72
|
-
var options = PropTypes__default['default'].arrayOf(PropTypes__default['default'].shape({
|
|
73
|
-
label: PropTypes__default['default'].string.isRequired,
|
|
74
|
-
value: PropTypes__default['default'].string.isRequired
|
|
75
|
-
}));
|
|
76
|
-
|
|
77
|
-
var response = PropTypes__default['default'].shape({
|
|
78
|
-
name: PropTypes__default['default'].string,
|
|
79
|
-
values: PropTypes__default['default'].shape({})
|
|
80
|
-
});
|
|
81
|
-
|
|
82
|
-
var valueType = PropTypes__default['default'].oneOf(['COLLECTED', 'PREVIOUS', 'FORCED', 'EDITED', 'INPUTED']);
|
|
83
|
-
|
|
84
|
-
var lines = PropTypes__default['default'].shape({
|
|
85
|
-
min: PropTypes__default['default'].number,
|
|
86
|
-
max: PropTypes__default['default'].number
|
|
87
|
-
});
|
|
88
|
-
|
|
89
|
-
var buildTooltip = function buildTooltip(response) {
|
|
90
|
-
if (!response || !response.values || Object.keys(response.values).length === 0) return {};
|
|
91
|
-
var values = response.values;
|
|
92
|
-
var edited = values[EDITED];
|
|
93
|
-
var forced = values[FORCED];
|
|
94
|
-
var collected = values[COLLECTED];
|
|
95
|
-
|
|
96
|
-
if (has(edited)) {
|
|
97
|
-
if (!has(forced)) return {
|
|
98
|
-
content: [{
|
|
99
|
-
key: 'Brute',
|
|
100
|
-
value: collected || ' - '
|
|
101
|
-
}],
|
|
102
|
-
imgName: 'editedImg'
|
|
103
|
-
};
|
|
104
|
-
return {
|
|
105
|
-
content: [{
|
|
106
|
-
key: 'Brute',
|
|
107
|
-
value: collected || ' - '
|
|
108
|
-
}, {
|
|
109
|
-
key: 'Correction automatique',
|
|
110
|
-
value: forced
|
|
111
|
-
}],
|
|
112
|
-
imgName: 'editedImg'
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
if (has(forced)) return {
|
|
117
|
-
content: [{
|
|
118
|
-
key: 'Brute',
|
|
119
|
-
value: collected || ' - '
|
|
120
|
-
}],
|
|
121
|
-
imgName: 'forcedImg'
|
|
122
|
-
};
|
|
123
|
-
return {};
|
|
124
|
-
};
|
|
125
|
-
|
|
126
|
-
var has = function has(status) {
|
|
127
|
-
return status !== undefined && status !== null;
|
|
128
|
-
};
|
|
129
|
-
|
|
130
|
-
function _defineProperty(obj, key, value) {
|
|
131
|
-
if (key in obj) {
|
|
132
|
-
Object.defineProperty(obj, key, {
|
|
133
|
-
value: value,
|
|
134
|
-
enumerable: true,
|
|
135
|
-
configurable: true,
|
|
136
|
-
writable: true
|
|
137
|
-
});
|
|
138
|
-
} else {
|
|
139
|
-
obj[key] = value;
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
return obj;
|
|
143
|
-
}
|
|
144
|
-
|
|
145
|
-
function _extends() {
|
|
146
|
-
_extends = Object.assign || function (target) {
|
|
147
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
148
|
-
var source = arguments[i];
|
|
149
|
-
|
|
150
|
-
for (var key in source) {
|
|
151
|
-
if (Object.prototype.hasOwnProperty.call(source, key)) {
|
|
152
|
-
target[key] = source[key];
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
return target;
|
|
158
|
-
};
|
|
159
|
-
|
|
160
|
-
return _extends.apply(this, arguments);
|
|
161
|
-
}
|
|
162
|
-
|
|
163
|
-
function ownKeys(object, enumerableOnly) {
|
|
164
|
-
var keys = Object.keys(object);
|
|
165
|
-
|
|
166
|
-
if (Object.getOwnPropertySymbols) {
|
|
167
|
-
var symbols = Object.getOwnPropertySymbols(object);
|
|
168
|
-
if (enumerableOnly) symbols = symbols.filter(function (sym) {
|
|
169
|
-
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
170
|
-
});
|
|
171
|
-
keys.push.apply(keys, symbols);
|
|
172
|
-
}
|
|
173
|
-
|
|
174
|
-
return keys;
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
function _objectSpread2(target) {
|
|
178
|
-
for (var i = 1; i < arguments.length; i++) {
|
|
179
|
-
var source = arguments[i] != null ? arguments[i] : {};
|
|
180
|
-
|
|
181
|
-
if (i % 2) {
|
|
182
|
-
ownKeys(Object(source), true).forEach(function (key) {
|
|
183
|
-
_defineProperty(target, key, source[key]);
|
|
184
|
-
});
|
|
185
|
-
} else if (Object.getOwnPropertyDescriptors) {
|
|
186
|
-
Object.defineProperties(target, Object.getOwnPropertyDescriptors(source));
|
|
187
|
-
} else {
|
|
188
|
-
ownKeys(Object(source)).forEach(function (key) {
|
|
189
|
-
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
190
|
-
});
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
|
|
194
|
-
return target;
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
function _objectWithoutPropertiesLoose(source, excluded) {
|
|
198
|
-
if (source == null) return {};
|
|
199
|
-
var target = {};
|
|
200
|
-
var sourceKeys = Object.keys(source);
|
|
201
|
-
var key, i;
|
|
202
|
-
|
|
203
|
-
for (i = 0; i < sourceKeys.length; i++) {
|
|
204
|
-
key = sourceKeys[i];
|
|
205
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
206
|
-
target[key] = source[key];
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
return target;
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
function _objectWithoutProperties(source, excluded) {
|
|
213
|
-
if (source == null) return {};
|
|
214
|
-
|
|
215
|
-
var target = _objectWithoutPropertiesLoose(source, excluded);
|
|
216
|
-
|
|
217
|
-
var key, i;
|
|
218
|
-
|
|
219
|
-
if (Object.getOwnPropertySymbols) {
|
|
220
|
-
var sourceSymbolKeys = Object.getOwnPropertySymbols(source);
|
|
221
|
-
|
|
222
|
-
for (i = 0; i < sourceSymbolKeys.length; i++) {
|
|
223
|
-
key = sourceSymbolKeys[i];
|
|
224
|
-
if (excluded.indexOf(key) >= 0) continue;
|
|
225
|
-
if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue;
|
|
226
|
-
target[key] = source[key];
|
|
227
|
-
}
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
return target;
|
|
231
|
-
}
|
|
232
|
-
|
|
233
|
-
function _slicedToArray(arr, i) {
|
|
234
|
-
return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest();
|
|
235
|
-
}
|
|
236
|
-
|
|
237
|
-
function _toArray(arr) {
|
|
238
|
-
return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest();
|
|
239
|
-
}
|
|
240
|
-
|
|
241
|
-
function _toConsumableArray(arr) {
|
|
242
|
-
return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread();
|
|
243
|
-
}
|
|
244
|
-
|
|
245
|
-
function _arrayWithoutHoles(arr) {
|
|
246
|
-
if (Array.isArray(arr)) return _arrayLikeToArray(arr);
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
function _arrayWithHoles(arr) {
|
|
250
|
-
if (Array.isArray(arr)) return arr;
|
|
251
|
-
}
|
|
252
|
-
|
|
253
|
-
function _iterableToArray(iter) {
|
|
254
|
-
if (typeof Symbol !== "undefined" && Symbol.iterator in Object(iter)) return Array.from(iter);
|
|
255
|
-
}
|
|
256
|
-
|
|
257
|
-
function _iterableToArrayLimit(arr, i) {
|
|
258
|
-
if (typeof Symbol === "undefined" || !(Symbol.iterator in Object(arr))) return;
|
|
259
|
-
var _arr = [];
|
|
260
|
-
var _n = true;
|
|
261
|
-
var _d = false;
|
|
262
|
-
var _e = undefined;
|
|
263
|
-
|
|
264
|
-
try {
|
|
265
|
-
for (var _i = arr[Symbol.iterator](), _s; !(_n = (_s = _i.next()).done); _n = true) {
|
|
266
|
-
_arr.push(_s.value);
|
|
267
|
-
|
|
268
|
-
if (i && _arr.length === i) break;
|
|
269
|
-
}
|
|
270
|
-
} catch (err) {
|
|
271
|
-
_d = true;
|
|
272
|
-
_e = err;
|
|
273
|
-
} finally {
|
|
274
|
-
try {
|
|
275
|
-
if (!_n && _i["return"] != null) _i["return"]();
|
|
276
|
-
} finally {
|
|
277
|
-
if (_d) throw _e;
|
|
278
|
-
}
|
|
279
|
-
}
|
|
280
|
-
|
|
281
|
-
return _arr;
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
function _unsupportedIterableToArray(o, minLen) {
|
|
285
|
-
if (!o) return;
|
|
286
|
-
if (typeof o === "string") return _arrayLikeToArray(o, minLen);
|
|
287
|
-
var n = Object.prototype.toString.call(o).slice(8, -1);
|
|
288
|
-
if (n === "Object" && o.constructor) n = o.constructor.name;
|
|
289
|
-
if (n === "Map" || n === "Set") return Array.from(o);
|
|
290
|
-
if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen);
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
function _arrayLikeToArray(arr, len) {
|
|
294
|
-
if (len == null || len > arr.length) len = arr.length;
|
|
295
|
-
|
|
296
|
-
for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i];
|
|
297
|
-
|
|
298
|
-
return arr2;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
function _nonIterableSpread() {
|
|
302
|
-
throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
303
|
-
}
|
|
304
|
-
|
|
305
|
-
function _nonIterableRest() {
|
|
306
|
-
throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
|
|
307
|
-
}
|
|
308
|
-
|
|
309
|
-
var interpret = function interpret(features) {
|
|
310
|
-
return function (bindings, doNotReplaceNullBindings) {
|
|
311
|
-
return function (expression) {
|
|
312
|
-
if (!expression) return '';
|
|
313
|
-
if (!Array.isArray(features)) return expression;
|
|
314
|
-
|
|
315
|
-
if (features.includes('VTL')) {
|
|
316
|
-
try {
|
|
317
|
-
var VTLExpr = vtl2_1Engine.interpret(expression, doNotReplaceNullBindings ? bindings : replaceNullBindings(bindings));
|
|
318
|
-
if (!VTLExpr) return expression;
|
|
319
|
-
return VTLExpr;
|
|
320
|
-
} catch (e) {
|
|
321
|
-
return expression;
|
|
322
|
-
}
|
|
323
|
-
}
|
|
324
|
-
|
|
325
|
-
return expression;
|
|
326
|
-
};
|
|
327
|
-
};
|
|
328
|
-
};
|
|
329
|
-
var interpretWithEmptyDefault = function interpretWithEmptyDefault(features, doNotReplaceNullBindings) {
|
|
330
|
-
return function (bindings, replaceNullBindings) {
|
|
331
|
-
return function (expression) {
|
|
332
|
-
if (!expression) return '';
|
|
333
|
-
if (!Array.isArray(features)) return expression;
|
|
334
|
-
|
|
335
|
-
if (features.includes('VTL')) {
|
|
336
|
-
try {
|
|
337
|
-
var VTLExpr = vtl2_1Engine.interpret(expression, doNotReplaceNullBindings ? bindings : replaceNullBindings(bindings, ''));
|
|
338
|
-
if (!VTLExpr) return '';
|
|
339
|
-
return VTLExpr;
|
|
340
|
-
} catch (e) {
|
|
341
|
-
return '';
|
|
342
|
-
}
|
|
343
|
-
}
|
|
344
|
-
|
|
345
|
-
return '';
|
|
346
|
-
};
|
|
347
|
-
};
|
|
348
|
-
};
|
|
349
|
-
var replaceNullBindings = function replaceNullBindings(bindings, defaultValue) {
|
|
350
|
-
return bindings ? Object.entries(bindings).reduce(function (acc, _ref) {
|
|
351
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
352
|
-
key = _ref2[0],
|
|
353
|
-
value = _ref2[1];
|
|
354
|
-
|
|
355
|
-
return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, key, value === null ? defaultValue || key : value));
|
|
356
|
-
}, {}) : {};
|
|
357
|
-
};
|
|
358
|
-
|
|
359
|
-
var mergeQuestionnaireAndData = function mergeQuestionnaireAndData(questionnaire) {
|
|
360
|
-
return function (data) {
|
|
361
|
-
if (!questionnaire || !questionnaire.components) return {};
|
|
362
|
-
if (questionnaire.components.length === 0) return questionnaire;
|
|
363
|
-
|
|
364
|
-
var components = questionnaire.components,
|
|
365
|
-
variables = questionnaire.variables,
|
|
366
|
-
props = _objectWithoutProperties(questionnaire, ["components", "variables"]);
|
|
367
|
-
|
|
368
|
-
var vars = buildVars(data || {})(variables);
|
|
369
|
-
var filledComponents = buildFilledComponents(vars[COLLECTED])(components)(0);
|
|
370
|
-
return _objectSpread2(_objectSpread2({}, props), {}, {
|
|
371
|
-
components: filledComponents,
|
|
372
|
-
variables: vars
|
|
373
|
-
});
|
|
374
|
-
};
|
|
375
|
-
};
|
|
376
|
-
|
|
377
|
-
var buildVars = function buildVars(data) {
|
|
378
|
-
return function (variables) {
|
|
379
|
-
if (!Array.isArray(variables)) return {};
|
|
380
|
-
var collectedData = data.COLLECTED;
|
|
381
|
-
var collected = variables.filter(function (_ref) {
|
|
382
|
-
var variableType = _ref.variableType;
|
|
383
|
-
return variableType === COLLECTED;
|
|
384
|
-
}).reduce(function (acc, _ref2) {
|
|
385
|
-
var values = _ref2.values,
|
|
386
|
-
name = _ref2.name,
|
|
387
|
-
componentRef = _ref2.componentRef;
|
|
388
|
-
var d = collectedData && collectedData[name] || {};
|
|
389
|
-
return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, name, {
|
|
390
|
-
componentRef: componentRef,
|
|
391
|
-
values: _objectSpread2(_objectSpread2({}, values), d)
|
|
392
|
-
}));
|
|
393
|
-
}, {});
|
|
394
|
-
var EXTERNAL$1 = variables.filter(function (_ref3) {
|
|
395
|
-
var variableType = _ref3.variableType;
|
|
396
|
-
return variableType === EXTERNAL;
|
|
397
|
-
}).reduce(function (_, v) {
|
|
398
|
-
return _objectSpread2(_objectSpread2({}, _), initExternalVariable(v)(data));
|
|
399
|
-
}, {});
|
|
400
|
-
return {
|
|
401
|
-
EXTERNAL: EXTERNAL$1,
|
|
402
|
-
COLLECTED: collected,
|
|
403
|
-
CALCULATED: variables.filter(function (_ref4) {
|
|
404
|
-
var variableType = _ref4.variableType;
|
|
405
|
-
return variableType === CALCULATED;
|
|
406
|
-
}).reduce(function (_, v) {
|
|
407
|
-
return _objectSpread2(_objectSpread2({}, _), initCalculatedVariable(v)(_objectSpread2(_objectSpread2({}, EXTERNAL$1), collected)));
|
|
408
|
-
}, {})
|
|
409
|
-
};
|
|
410
|
-
};
|
|
411
|
-
};
|
|
412
|
-
|
|
413
|
-
var buildFilledComponents = function buildFilledComponents(vars) {
|
|
414
|
-
return function (components) {
|
|
415
|
-
return function (depth) {
|
|
416
|
-
return components.map(function (c) {
|
|
417
|
-
var component = _objectSpread2({
|
|
418
|
-
depth: depth
|
|
419
|
-
}, c);
|
|
420
|
-
|
|
421
|
-
return buildFilledComponent(vars)(component);
|
|
422
|
-
});
|
|
423
|
-
};
|
|
424
|
-
};
|
|
425
|
-
};
|
|
426
|
-
|
|
427
|
-
var buildFilledComponent = function buildFilledComponent(vars) {
|
|
428
|
-
return function (component) {
|
|
429
|
-
if (component.response) return buildResponseComponent(vars)(component);else if (component.responses) return buildResponsesComponent(vars)(component);else if (component.cells) return buildCellsComponent(vars)(component);else if (component.components) return buildComponentsComponent(vars)(component);
|
|
430
|
-
return component;
|
|
431
|
-
};
|
|
432
|
-
};
|
|
433
|
-
var buildResponseComponent = function buildResponseComponent(vars) {
|
|
434
|
-
return function (c) {
|
|
435
|
-
return _objectSpread2(_objectSpread2({}, c), {}, {
|
|
436
|
-
response: {
|
|
437
|
-
name: c.response.name,
|
|
438
|
-
values: vars[c.response.name].values
|
|
439
|
-
}
|
|
440
|
-
});
|
|
441
|
-
};
|
|
442
|
-
};
|
|
443
|
-
var buildResponsesComponent = function buildResponsesComponent(vars) {
|
|
444
|
-
return function (c) {
|
|
445
|
-
var responses = c.responses,
|
|
446
|
-
rest = _objectWithoutProperties(c, ["responses"]);
|
|
447
|
-
|
|
448
|
-
var filledResponses = responses.map(function (r) {
|
|
449
|
-
return buildResponseComponent(vars)(r);
|
|
450
|
-
});
|
|
451
|
-
return _objectSpread2(_objectSpread2({}, rest), {}, {
|
|
452
|
-
responses: filledResponses
|
|
453
|
-
});
|
|
454
|
-
};
|
|
455
|
-
};
|
|
456
|
-
var buildCellsComponent = function buildCellsComponent(vars) {
|
|
457
|
-
return function (c) {
|
|
458
|
-
var cells = c.cells,
|
|
459
|
-
depth = c.depth,
|
|
460
|
-
rest = _objectWithoutProperties(c, ["cells", "depth"]);
|
|
461
|
-
|
|
462
|
-
var filledCells = cells.map(function (row) {
|
|
463
|
-
return buildFilledComponents(vars)(row)(depth);
|
|
464
|
-
});
|
|
465
|
-
return _objectSpread2(_objectSpread2({}, rest), {}, {
|
|
466
|
-
depth: depth,
|
|
467
|
-
cells: filledCells
|
|
468
|
-
});
|
|
469
|
-
};
|
|
470
|
-
};
|
|
471
|
-
var buildComponentsComponent = function buildComponentsComponent(vars) {
|
|
472
|
-
return function (component) {
|
|
473
|
-
var components = component.components,
|
|
474
|
-
depth = component.depth,
|
|
475
|
-
rest = _objectWithoutProperties(component, ["components", "depth"]);
|
|
476
|
-
|
|
477
|
-
var filledComponents = buildFilledComponents(vars)(components)(depth + 1);
|
|
478
|
-
return _objectSpread2(_objectSpread2({}, rest), {}, {
|
|
479
|
-
depth: depth,
|
|
480
|
-
components: filledComponents
|
|
481
|
-
});
|
|
482
|
-
};
|
|
483
|
-
};
|
|
484
|
-
|
|
485
|
-
var initExternalVariable = function initExternalVariable(_ref5) {
|
|
486
|
-
var name = _ref5.name;
|
|
487
|
-
return function (data) {
|
|
488
|
-
return _defineProperty({}, name, data && data.EXTERNAL && data.EXTERNAL[name] || null);
|
|
489
|
-
};
|
|
490
|
-
};
|
|
491
|
-
|
|
492
|
-
var initCalculatedVariable = function initCalculatedVariable(_ref7) {
|
|
493
|
-
var name = _ref7.name,
|
|
494
|
-
expression = _ref7.expression;
|
|
495
|
-
return function (data) {
|
|
496
|
-
var bindings = Object.entries(data).reduce(function (acc, _ref8) {
|
|
497
|
-
var _ref9 = _slicedToArray(_ref8, 2),
|
|
498
|
-
key = _ref9[0],
|
|
499
|
-
value = _ref9[1];
|
|
500
|
-
|
|
501
|
-
return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, key, typeof value === 'string' || value === null ? value : value.values[COLLECTED]));
|
|
502
|
-
}, {});
|
|
503
|
-
return _defineProperty({}, name, {
|
|
504
|
-
expression: expression,
|
|
505
|
-
value: interpret(['VTL'])(bindings)(expression)
|
|
506
|
-
});
|
|
507
|
-
};
|
|
508
|
-
};
|
|
509
|
-
|
|
510
|
-
var supportedPreferences = [PREVIOUS, COLLECTED, FORCED, EDITED, INPUTED];
|
|
511
|
-
|
|
512
|
-
var buildBindingsForDeeperComponents = function buildBindingsForDeeperComponents(index) {
|
|
513
|
-
return function (bindings) {
|
|
514
|
-
return bindings ? Object.entries(bindings).reduce(function (_, _ref) {
|
|
515
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
516
|
-
name = _ref2[0],
|
|
517
|
-
value = _ref2[1];
|
|
518
|
-
|
|
519
|
-
if (Array.isArray(value)) return _objectSpread2(_objectSpread2({}, _), {}, _defineProperty({}, name, value[index] || null));
|
|
520
|
-
return _objectSpread2(_objectSpread2({}, _), {}, _defineProperty({}, name, value));
|
|
521
|
-
}, {}) : {};
|
|
522
|
-
};
|
|
523
|
-
};
|
|
524
|
-
|
|
525
|
-
var getDefaultDatasetStructure = function getDefaultDatasetStructure(name, value) {
|
|
526
|
-
return _defineProperty({}, name, {
|
|
527
|
-
dataStructure: {},
|
|
528
|
-
dataPoints: _defineProperty({}, name, value)
|
|
529
|
-
});
|
|
530
|
-
};
|
|
531
|
-
|
|
532
|
-
var buildVectorialBindings = function buildVectorialBindings(bindings) {
|
|
533
|
-
return bindings ? Object.entries(bindings).reduce(function (_, _ref4) {
|
|
534
|
-
var _ref5 = _slicedToArray(_ref4, 2),
|
|
535
|
-
name = _ref5[0],
|
|
536
|
-
value = _ref5[1];
|
|
537
|
-
|
|
538
|
-
if (Array.isArray(value)) return _objectSpread2(_objectSpread2({}, _), getDefaultDatasetStructure(name, value));
|
|
539
|
-
return _objectSpread2(_objectSpread2({}, _), {}, _defineProperty({}, name, value));
|
|
540
|
-
}, {}) : {};
|
|
541
|
-
};
|
|
542
|
-
var displayLoop = function displayLoop(dependencyList) {
|
|
543
|
-
return function (bindings) {
|
|
544
|
-
if (!Array.isArray(dependencyList) || !bindings) return false;
|
|
545
|
-
return !(dependencyList.map(function (iv) {
|
|
546
|
-
return Array.isArray(bindings[iv][0]) ? bindings[iv][0].flat()[0] : bindings[iv][0];
|
|
547
|
-
}).filter(function (v) {
|
|
548
|
-
return v;
|
|
549
|
-
}).length === 0);
|
|
550
|
-
};
|
|
551
|
-
};
|
|
552
|
-
var displayLoopQuestion = function displayLoopQuestion(dependencyList) {
|
|
553
|
-
return function (bindings) {
|
|
554
|
-
if (!Array.isArray(dependencyList) || !bindings) return false;
|
|
555
|
-
return !(dependencyList.map(function (iv) {
|
|
556
|
-
return Array.isArray(bindings[iv]) ? bindings[iv].flat()[0] : bindings[iv];
|
|
557
|
-
}).filter(function (v) {
|
|
558
|
-
return v;
|
|
559
|
-
}).length === 0);
|
|
560
|
-
};
|
|
561
|
-
};
|
|
562
|
-
|
|
563
|
-
var updateQuestionnaire = function updateQuestionnaire(valueType) {
|
|
564
|
-
return function (questionnaire) {
|
|
565
|
-
return function (preferences) {
|
|
566
|
-
return function (updatedValues) {
|
|
567
|
-
if (!supportedPreferences.includes(valueType) || preferences.length === 0 || !updatedValues) return questionnaire;
|
|
568
|
-
|
|
569
|
-
var variables = questionnaire.variables,
|
|
570
|
-
components = questionnaire.components,
|
|
571
|
-
other = _objectWithoutProperties(questionnaire, ["variables", "components"]);
|
|
572
|
-
|
|
573
|
-
if (!components || components.length === 0) return questionnaire;
|
|
574
|
-
var varsAndRefs = Object.entries(updatedValues).reduce(function (acc, _ref) {
|
|
575
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
576
|
-
key = _ref2[0],
|
|
577
|
-
value = _ref2[1];
|
|
578
|
-
|
|
579
|
-
var _acc$newVariables = acc.newVariables,
|
|
580
|
-
COLLECTED = _acc$newVariables.COLLECTED,
|
|
581
|
-
otherVars = _objectWithoutProperties(_acc$newVariables, ["COLLECTED"]),
|
|
582
|
-
refs = acc.refs;
|
|
583
|
-
|
|
584
|
-
var _COLLECTED$key = COLLECTED[key],
|
|
585
|
-
componentRef = _COLLECTED$key.componentRef,
|
|
586
|
-
values = _COLLECTED$key.values;
|
|
587
|
-
var updated = {
|
|
588
|
-
componentRef: componentRef,
|
|
589
|
-
values: _objectSpread2(_objectSpread2({}, values), {}, _defineProperty({}, valueType, buildNewValue(preferences)(valueType)(values)(value)))
|
|
590
|
-
};
|
|
591
|
-
|
|
592
|
-
var newCollected = _objectSpread2(_objectSpread2({}, COLLECTED), {}, _defineProperty({}, key, updated));
|
|
593
|
-
|
|
594
|
-
return {
|
|
595
|
-
newVariables: _objectSpread2(_objectSpread2({}, otherVars), {}, {
|
|
596
|
-
COLLECTED: newCollected
|
|
597
|
-
}),
|
|
598
|
-
refs: [].concat(_toConsumableArray(refs), [componentRef])
|
|
599
|
-
};
|
|
600
|
-
}, {
|
|
601
|
-
newVariables: variables,
|
|
602
|
-
refs: []
|
|
603
|
-
});
|
|
604
|
-
var newVariables = varsAndRefs.newVariables,
|
|
605
|
-
r = varsAndRefs.refs;
|
|
606
|
-
var newVariablesWithCalculated = valueType === COLLECTED ? addCalculatedVars(newVariables) : newVariables;
|
|
607
|
-
var collectedVars = newVariables[COLLECTED];
|
|
608
|
-
var newComponents = components.map(function (c) {
|
|
609
|
-
if (r.includes(c.id)) return buildFilledComponent(collectedVars)(c);
|
|
610
|
-
return c;
|
|
611
|
-
});
|
|
612
|
-
return _objectSpread2(_objectSpread2({}, other), {}, {
|
|
613
|
-
variables: newVariablesWithCalculated,
|
|
614
|
-
components: newComponents
|
|
615
|
-
});
|
|
616
|
-
};
|
|
617
|
-
};
|
|
618
|
-
};
|
|
619
|
-
};
|
|
620
|
-
var buildNewValue = function buildNewValue(preferences) {
|
|
621
|
-
return function (valueType) {
|
|
622
|
-
return function (oldValues) {
|
|
623
|
-
return function (value) {
|
|
624
|
-
if (preferences.length === 1) return value;
|
|
625
|
-
var index = preferences.indexOf(valueType);
|
|
626
|
-
if (index < 1) return value;
|
|
627
|
-
var valuesByPreference = preferences.slice(0, index).map(function (p) {
|
|
628
|
-
return oldValues[p];
|
|
629
|
-
}).filter(function (v) {
|
|
630
|
-
return v !== null;
|
|
631
|
-
});
|
|
632
|
-
var lastValue = valuesByPreference[valuesByPreference.length - 1];
|
|
633
|
-
return lastValue === value ? null : value;
|
|
634
|
-
};
|
|
635
|
-
};
|
|
636
|
-
};
|
|
637
|
-
};
|
|
638
|
-
|
|
639
|
-
var addCalculatedVars = function addCalculatedVars(variables) {
|
|
640
|
-
if (!variables[CALCULATED] || Object.keys(variables[CALCULATED]).length === 0) return variables;
|
|
641
|
-
var COLLECTED$1 = variables.COLLECTED,
|
|
642
|
-
EXTERNAL = variables.EXTERNAL,
|
|
643
|
-
CALCULATED$1 = variables.CALCULATED;
|
|
644
|
-
var collected = Object.entries(COLLECTED$1).reduce(function (acc, _ref3) {
|
|
645
|
-
var _ref4 = _slicedToArray(_ref3, 2),
|
|
646
|
-
key = _ref4[0],
|
|
647
|
-
values = _ref4[1].values;
|
|
648
|
-
|
|
649
|
-
return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, key, values[COLLECTED]));
|
|
650
|
-
}, {});
|
|
651
|
-
var bindings = buildVectorialBindings(_objectSpread2(_objectSpread2({}, collected), EXTERNAL));
|
|
652
|
-
var calculated = Object.entries(CALCULATED$1).reduce(function (acc, _ref5) {
|
|
653
|
-
var _ref6 = _slicedToArray(_ref5, 2),
|
|
654
|
-
key = _ref6[0],
|
|
655
|
-
expression = _ref6[1].expression;
|
|
656
|
-
|
|
657
|
-
// Assume that a calculated variable has a first level scope
|
|
658
|
-
// If we need to handle deep calculated variables, we have to
|
|
659
|
-
// update the shape of bindings, grouping vars by type
|
|
660
|
-
var res = interpret(['VTL'])(bindings)(expression);
|
|
661
|
-
var value = Array.isArray(res) ? res.join(',') : res;
|
|
662
|
-
return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, key, {
|
|
663
|
-
expression: expression,
|
|
664
|
-
value: value
|
|
665
|
-
}));
|
|
666
|
-
}, {});
|
|
667
|
-
return {
|
|
668
|
-
EXTERNAL: EXTERNAL,
|
|
669
|
-
COLLECTED: COLLECTED$1,
|
|
670
|
-
CALCULATED: calculated
|
|
671
|
-
};
|
|
672
|
-
};
|
|
673
|
-
|
|
674
|
-
var buildMultiTooltipResponse = function buildMultiTooltipResponse(options) {
|
|
675
|
-
return function (response) {
|
|
676
|
-
if (!response || Object.keys(response).length === 0 || !options) return {};
|
|
677
|
-
var name = response.name,
|
|
678
|
-
values = response.values;
|
|
679
|
-
var newValues = Object.entries(values).reduce(function (acc, _ref) {
|
|
680
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
681
|
-
k = _ref2[0],
|
|
682
|
-
v = _ref2[1];
|
|
683
|
-
|
|
684
|
-
return v === null ? _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, k, v)) : _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, k, options.find(function (o) {
|
|
685
|
-
return o.value === v;
|
|
686
|
-
}).label));
|
|
687
|
-
}, {});
|
|
688
|
-
return {
|
|
689
|
-
name: name,
|
|
690
|
-
values: newValues
|
|
691
|
-
};
|
|
692
|
-
};
|
|
693
|
-
};
|
|
694
|
-
var buildBooleanTooltipResponse = function buildBooleanTooltipResponse(response) {
|
|
695
|
-
if (!response || Object.keys(response).length === 0) return {};
|
|
696
|
-
var name = response.name,
|
|
697
|
-
values = response.values;
|
|
698
|
-
var newValues = Object.entries(values).reduce(function (acc, _ref3) {
|
|
699
|
-
var _ref4 = _slicedToArray(_ref3, 2),
|
|
700
|
-
k = _ref4[0],
|
|
701
|
-
v = _ref4[1];
|
|
702
|
-
|
|
703
|
-
return v === null ? _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, k, v)) : _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, k, v ? 'Vrai' : 'Faux'));
|
|
704
|
-
}, {});
|
|
705
|
-
return {
|
|
706
|
-
name: name,
|
|
707
|
-
values: newValues
|
|
708
|
-
};
|
|
709
|
-
};
|
|
710
|
-
/**
|
|
711
|
-
* Assume we use this tool in management mode only
|
|
712
|
-
*/
|
|
713
|
-
|
|
714
|
-
var buildLocalResponse = function buildLocalResponse(response, value) {
|
|
715
|
-
if (!response || Object.keys(response).length === 0) return {};
|
|
716
|
-
var name = response.name,
|
|
717
|
-
values = response.values;
|
|
718
|
-
var newValue = buildNewValue([COLLECTED, FORCED, EDITED])(EDITED)(values)(value);
|
|
719
|
-
return {
|
|
720
|
-
name: name,
|
|
721
|
-
values: _objectSpread2(_objectSpread2({}, values), {}, {
|
|
722
|
-
EDITED: newValue
|
|
723
|
-
})
|
|
724
|
-
};
|
|
725
|
-
};
|
|
726
|
-
|
|
727
|
-
var getAlphabet = function getAlphabet() {
|
|
728
|
-
return 'abcdefghijklmnopqrstuvwxyz'.split('');
|
|
729
|
-
};
|
|
730
|
-
|
|
731
|
-
var getLabelPositionClass = function getLabelPositionClass(position) {
|
|
732
|
-
switch (position) {
|
|
733
|
-
case 'LEFT':
|
|
734
|
-
return 'label-left';
|
|
735
|
-
|
|
736
|
-
case 'BOTTOM':
|
|
737
|
-
return 'label-bottom';
|
|
738
|
-
|
|
739
|
-
case 'RIGHT':
|
|
740
|
-
return 'label-right';
|
|
741
|
-
|
|
742
|
-
default:
|
|
743
|
-
return 'label-top';
|
|
744
|
-
}
|
|
745
|
-
};
|
|
746
|
-
|
|
747
|
-
var getItemsPositioningClass = function getItemsPositioningClass(positioning) {
|
|
748
|
-
switch (positioning) {
|
|
749
|
-
case 'HORIZONTAL':
|
|
750
|
-
return 'horizontal-options';
|
|
751
|
-
|
|
752
|
-
case 'VERTICAL':
|
|
753
|
-
default:
|
|
754
|
-
return '';
|
|
755
|
-
}
|
|
756
|
-
};
|
|
757
|
-
|
|
758
|
-
var getResponseName = function getResponseName(response) {
|
|
759
|
-
return response && response.name || '';
|
|
760
|
-
};
|
|
761
|
-
var getResponseByPreference = function getResponseByPreference(preferences) {
|
|
762
|
-
return function (response) {
|
|
763
|
-
if (!(response && response.values)) return null;
|
|
764
|
-
return preferences.reduce(function (acc, p) {
|
|
765
|
-
var value = response.values[p];
|
|
766
|
-
return value !== null ? value : acc;
|
|
767
|
-
}, null);
|
|
768
|
-
};
|
|
769
|
-
};
|
|
770
|
-
|
|
771
|
-
var buildStyleObject = function buildStyleObject(obj) {
|
|
772
|
-
return obj ? Object.entries(obj).reduce(function (_, _ref) {
|
|
773
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
774
|
-
key = _ref2[0],
|
|
775
|
-
value = _ref2[1];
|
|
776
|
-
|
|
777
|
-
if (key.startsWith(':')) _[key] = buildStyleObject(value);else _[camelCase__default['default'](key)] = value;
|
|
778
|
-
return _;
|
|
779
|
-
}, {}) : {};
|
|
780
|
-
};
|
|
781
|
-
|
|
782
|
-
var isResponseEmpty = function isResponseEmpty(response) {
|
|
783
|
-
return Object.values(response.values).filter(function (v) {
|
|
784
|
-
return v !== null;
|
|
785
|
-
}).length === 0;
|
|
786
|
-
};
|
|
787
|
-
|
|
788
|
-
var getRosterInitLines = function getRosterInitLines(cells) {
|
|
789
|
-
return Array.isArray(cells) ? cells.reduce(function (_, line) {
|
|
790
|
-
return [].concat(_toConsumableArray(_), [line.reduce(function (__, component) {
|
|
791
|
-
if (!component.response || __) return __;
|
|
792
|
-
return !isResponseEmpty(component.response);
|
|
793
|
-
}, false)]);
|
|
794
|
-
}, []).filter(function (b) {
|
|
795
|
-
return b;
|
|
796
|
-
}).length : 0;
|
|
797
|
-
};
|
|
798
|
-
|
|
799
|
-
var getLoopConstructorInitLines = function getLoopConstructorInitLines(components) {
|
|
800
|
-
return Array.isArray(components) ? components.reduce(function (_, c) {
|
|
801
|
-
return c.response && c.response.values[COLLECTED] && c.response.values[COLLECTED].length > _ ? c.response.values[COLLECTED].length : _;
|
|
802
|
-
}, 0) : 0;
|
|
803
|
-
};
|
|
804
|
-
var getInvolvedVariables = function getInvolvedVariables(parentComponents) {
|
|
805
|
-
return Array.isArray(parentComponents) ? parentComponents.reduce(function (_, c) {
|
|
806
|
-
var response = c.response,
|
|
807
|
-
responses = c.responses,
|
|
808
|
-
components = c.components,
|
|
809
|
-
depth = c.depth;
|
|
810
|
-
if (response && response.name) return [].concat(_toConsumableArray(_), [{
|
|
811
|
-
name: response.name,
|
|
812
|
-
depth: depth
|
|
813
|
-
}]);
|
|
814
|
-
if (responses || components) return [].concat(_toConsumableArray(_), [getInvolvedVariables(responses || components)]);
|
|
815
|
-
return _;
|
|
816
|
-
}, []).flat() : [];
|
|
817
|
-
};
|
|
818
|
-
var lastLoopChildLineIsEmpty = function lastLoopChildLineIsEmpty(bindings) {
|
|
819
|
-
return function (involvedVariables) {
|
|
820
|
-
return bindings && involvedVariables ? involvedVariables.map(function (iv) {
|
|
821
|
-
return iv.name;
|
|
822
|
-
}).filter(function (iv) {
|
|
823
|
-
return bindings[iv] && bindings[iv][bindings[iv].length - 1];
|
|
824
|
-
}).length === 0 : true;
|
|
825
|
-
};
|
|
826
|
-
};
|
|
827
|
-
var buildEmptyValue = function buildEmptyValue(depth) {
|
|
828
|
-
if (!depth || depth === 1) return null;
|
|
829
|
-
return new Array(depth - 1).fill(null).reduce(function (acc) {
|
|
830
|
-
return new Array(1).fill(acc);
|
|
831
|
-
}, null);
|
|
832
|
-
};
|
|
833
|
-
|
|
834
|
-
var VarsHasBeenUpdated = function VarsHasBeenUpdated(prevProps, props) {
|
|
835
|
-
var oldR = prevProps.response,
|
|
836
|
-
oldRs = prevProps.responses,
|
|
837
|
-
oldC = prevProps.cells;
|
|
838
|
-
var newR = props.response,
|
|
839
|
-
newRs = props.responses,
|
|
840
|
-
newC = props.cells;
|
|
841
|
-
if (!newR && !newRs && !newC) return true;
|
|
842
|
-
return !(newR && isEqual__default['default'](oldR, newR) || newRs && isEqual__default['default'](oldRs, newRs) || newC && isEqual__default['default'](oldC, newC));
|
|
843
|
-
};
|
|
844
|
-
|
|
845
|
-
var areEqual = function areEqual(prevProps, props) {
|
|
846
|
-
if (VarsHasBeenUpdated(prevProps, props)) return false;
|
|
847
|
-
var bindingDependencies = props.bindingDependencies;
|
|
848
|
-
|
|
849
|
-
if (Array.isArray(bindingDependencies) && bindingDependencies.length > 0) {
|
|
850
|
-
var oldB = prevProps.bindings;
|
|
851
|
-
var newB = props.bindings;
|
|
852
|
-
return !bindingDependencies.map(function (d) {
|
|
853
|
-
return isEqual__default['default'](oldB[d], newB[d]);
|
|
854
|
-
}).includes(false);
|
|
855
|
-
}
|
|
856
|
-
|
|
857
|
-
return true;
|
|
858
|
-
};
|
|
859
|
-
|
|
860
|
-
var responseToClean = function responseToClean(response) {
|
|
861
|
-
return function (preferences) {
|
|
862
|
-
if (!preferences || !response.values) return false;
|
|
863
|
-
var values = response.values;
|
|
864
|
-
if (!values) return false;
|
|
865
|
-
|
|
866
|
-
var cutedValues = _objectSpread2(_objectSpread2({}, values), {}, _defineProperty({}, preferences[preferences.length - 1], null));
|
|
867
|
-
|
|
868
|
-
return Object.values(cutedValues).filter(function (v) {
|
|
869
|
-
return v !== null;
|
|
870
|
-
}).length === 0;
|
|
871
|
-
};
|
|
872
|
-
};
|
|
873
|
-
var responsesToClean = function responsesToClean(responses) {
|
|
874
|
-
return function (preferences) {
|
|
875
|
-
return function (key) {
|
|
876
|
-
if (!preferences || !key) return false;
|
|
877
|
-
var values = responses.find(function (r) {
|
|
878
|
-
return r.response.name === key;
|
|
879
|
-
}).response.values;
|
|
880
|
-
if (!values) return false;
|
|
881
|
-
|
|
882
|
-
var cutedValues = _objectSpread2(_objectSpread2({}, values), {}, _defineProperty({}, preferences[preferences.length - 1], null));
|
|
883
|
-
|
|
884
|
-
return Object.values(cutedValues).filter(function (v) {
|
|
885
|
-
return v !== null;
|
|
886
|
-
}).length === 0;
|
|
887
|
-
};
|
|
888
|
-
};
|
|
889
|
-
};
|
|
890
|
-
|
|
891
|
-
function styleInject(css, ref) {
|
|
892
|
-
if ( ref === void 0 ) ref = {};
|
|
893
|
-
var insertAt = ref.insertAt;
|
|
894
|
-
|
|
895
|
-
if (!css || typeof document === 'undefined') { return; }
|
|
896
|
-
|
|
897
|
-
var head = document.head || document.getElementsByTagName('head')[0];
|
|
898
|
-
var style = document.createElement('style');
|
|
899
|
-
style.type = 'text/css';
|
|
900
|
-
|
|
901
|
-
if (insertAt === 'top') {
|
|
902
|
-
if (head.firstChild) {
|
|
903
|
-
head.insertBefore(style, head.firstChild);
|
|
904
|
-
} else {
|
|
905
|
-
head.appendChild(style);
|
|
906
|
-
}
|
|
907
|
-
} else {
|
|
908
|
-
head.appendChild(style);
|
|
909
|
-
}
|
|
910
|
-
|
|
911
|
-
if (style.styleSheet) {
|
|
912
|
-
style.styleSheet.cssText = css;
|
|
913
|
-
} else {
|
|
914
|
-
style.appendChild(document.createTextNode(css));
|
|
915
|
-
}
|
|
916
|
-
}
|
|
917
|
-
|
|
918
|
-
var css_248z = "* {\n box-sizing: border-box;\n}\n\n.mandatory:after {\n content: \" *\";\n color: red;\n}\n\n.horizontal-options {\n display: inline-block;\n margin-right: 2em;\n}\n\nlabel,\n.lunatic-dropdown-label {\n margin-bottom: 0.5em;\n}\n\n.label-top {\n display: flex;\n flex-direction: column;\n}\n\n.label-bottom {\n display: flex;\n flex-direction: column-reverse;\n}\n\n.label-right {\n justify-content: flex-end;\n display: flex;\n flex-direction: row-reverse;\n align-items: baseline;\n}\n.label-right :first-child {\n margin-right: 1rem;\n}\n\n.label-left {\n display: flex;\n flex-direction: row;\n align-items: baseline;\n}\n.label-left :first-child {\n margin-right: 1rem;\n}\n\n.field-container {\n display: flex;\n}\n\n.tooltip {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n.field-with-tooltip {\n width: calc(100% - 25px);\n position: relative;\n}\n\n.field {\n width: 100%;\n position: relative;\n}\n\n.breadcrumb-lunatic {\n width: 100%;\n height: 40px;\n box-sizing: border-box;\n border-radius: 0px;\n background-color: #e80a4d;\n color: white;\n font-weight: bold;\n font-size: 130%;\n padding-left: 10px;\n display: flex;\n align-items: center;\n}\n\n.breadcrumb-element-lunatic:before {\n content: \">\";\n color: white;\n margin-left: 0.4em;\n margin-right: 0.4em;\n}";
|
|
919
|
-
styleInject(css_248z);
|
|
920
|
-
|
|
921
|
-
var Breadcrumb = function Breadcrumb(_ref) {
|
|
922
|
-
var elements = _ref.elements,
|
|
923
|
-
style = _ref.style;
|
|
924
|
-
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
925
|
-
"aria-label": "breadcrumb",
|
|
926
|
-
className: "breadcrumb-lunatic",
|
|
927
|
-
style: buildStyleObject(style)
|
|
928
|
-
}, elements.map(function (e, i) {
|
|
929
|
-
return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, {
|
|
930
|
-
key: "breadcrumb-".concat(e.toLowerCase())
|
|
931
|
-
}, e && /*#__PURE__*/React__default['default'].createElement("span", {
|
|
932
|
-
className: i !== 0 ? 'breadcrumb-element-lunatic' : undefined
|
|
933
|
-
}, e));
|
|
934
|
-
}));
|
|
935
|
-
};
|
|
936
|
-
|
|
937
|
-
Breadcrumb.propTypes = {
|
|
938
|
-
elements: PropTypes__default['default'].arrayOf(PropTypes__default['default'].string).isRequired,
|
|
939
|
-
style: PropTypes__default['default'].object
|
|
940
|
-
};
|
|
941
|
-
|
|
942
|
-
var css_248z$1 = "* {\n box-sizing: border-box;\n}\n\n.mandatory:after {\n content: \" *\";\n color: red;\n}\n\n.horizontal-options {\n display: inline-block;\n margin-right: 2em;\n}\n\nlabel,\n.lunatic-dropdown-label {\n margin-bottom: 0.5em;\n}\n\n.label-top {\n display: flex;\n flex-direction: column;\n}\n\n.label-bottom {\n display: flex;\n flex-direction: column-reverse;\n}\n\n.label-right {\n justify-content: flex-end;\n display: flex;\n flex-direction: row-reverse;\n align-items: baseline;\n}\n.label-right :first-child {\n margin-right: 1rem;\n}\n\n.label-left {\n display: flex;\n flex-direction: row;\n align-items: baseline;\n}\n.label-left :first-child {\n margin-right: 1rem;\n}\n\n.field-container {\n display: flex;\n}\n\n.tooltip {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n.field-with-tooltip {\n width: calc(100% - 25px);\n position: relative;\n}\n\n.field {\n width: 100%;\n position: relative;\n}\n\n.button-lunatic {\n width: 100%;\n color: white;\n border-color: #e80a4d;\n background-color: #e80a4d;\n font-size: 1.5em;\n font-weight: bold;\n padding: 0.4em;\n}\n.button-lunatic:hover, .button-lunatic:focus:hover {\n color: #e80a4d;\n background-color: white;\n border-color: #e80a4d;\n}\n.button-lunatic:focus {\n outline: none;\n background-color: #e07898;\n border-color: #e07898;\n}\n.button-lunatic:disabled {\n background: #dddddd;\n color: #e80a4d;\n}";
|
|
943
|
-
styleInject(css_248z$1);
|
|
944
|
-
|
|
945
|
-
var Button = function Button(_ref) {
|
|
946
|
-
var label = _ref.label,
|
|
947
|
-
value = _ref.value,
|
|
948
|
-
onClick = _ref.onClick,
|
|
949
|
-
disabled = _ref.disabled,
|
|
950
|
-
style = _ref.style;
|
|
951
|
-
return /*#__PURE__*/React__default['default'].createElement("button", {
|
|
952
|
-
type: "button",
|
|
953
|
-
"aria-label": label || 'button',
|
|
954
|
-
className: "button-lunatic",
|
|
955
|
-
style: buildStyleObject(style),
|
|
956
|
-
disabled: disabled,
|
|
957
|
-
onClick: onClick
|
|
958
|
-
}, value);
|
|
959
|
-
};
|
|
960
|
-
|
|
961
|
-
Button.propTypes = {
|
|
962
|
-
value: PropTypes__default['default'].string.isRequired,
|
|
963
|
-
disabled: PropTypes__default['default'].bool,
|
|
964
|
-
onClick: PropTypes__default['default'].func.isRequired
|
|
965
|
-
};
|
|
966
|
-
|
|
967
|
-
var getState = function getState(questionnaire) {
|
|
968
|
-
var _ref;
|
|
969
|
-
|
|
970
|
-
var variables = questionnaire.variables;
|
|
971
|
-
return _ref = {}, _defineProperty(_ref, CALCULATED, getCalculatedFromVariables(variables)), _defineProperty(_ref, COLLECTED, getCollectedState(questionnaire)), _defineProperty(_ref, EXTERNAL, getExternalFromVariables(variables)), _ref;
|
|
972
|
-
};
|
|
973
|
-
var getCollectedState = function getCollectedState(questionnaire) {
|
|
974
|
-
var variables = questionnaire.variables;
|
|
975
|
-
return variables && variables[COLLECTED] && Object.entries(variables[COLLECTED]).reduce(function (acc, _ref2) {
|
|
976
|
-
var _ref3 = _slicedToArray(_ref2, 2),
|
|
977
|
-
name = _ref3[0],
|
|
978
|
-
values = _ref3[1].values;
|
|
979
|
-
|
|
980
|
-
return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, name, values));
|
|
981
|
-
}, {}) || {};
|
|
982
|
-
};
|
|
983
|
-
|
|
984
|
-
var getCalculatedFromVariables = function getCalculatedFromVariables(variables) {
|
|
985
|
-
return variables && variables[CALCULATED] ? Object.entries(variables[CALCULATED]).reduce(function (_, _ref4) {
|
|
986
|
-
var _ref5 = _slicedToArray(_ref4, 2),
|
|
987
|
-
name = _ref5[0],
|
|
988
|
-
value = _ref5[1].value;
|
|
989
|
-
|
|
990
|
-
return _objectSpread2(_objectSpread2({}, _), {}, _defineProperty({}, name, value));
|
|
991
|
-
}, {}) : {};
|
|
992
|
-
};
|
|
993
|
-
|
|
994
|
-
var getExternalFromVariables = function getExternalFromVariables(variables) {
|
|
995
|
-
return variables && variables[EXTERNAL] || {};
|
|
996
|
-
};
|
|
997
|
-
|
|
998
|
-
var getCollectedStateByValueType = function getCollectedStateByValueType(questionnaire) {
|
|
999
|
-
return function (valueType, displayNull) {
|
|
1000
|
-
return ['PREVIOUS', 'COLLECTED', 'FORCED', 'EDITED', 'INPUTED'].includes(valueType) ? Object.entries(getCollectedState(questionnaire)).reduce(function (_, v) {
|
|
1001
|
-
if (displayNull || v[1][valueType] !== null) return _objectSpread2(_objectSpread2({}, _), {}, _defineProperty({}, v[0], v[1][valueType]));
|
|
1002
|
-
return _;
|
|
1003
|
-
}, {}) : {};
|
|
1004
|
-
};
|
|
1005
|
-
};
|
|
1006
|
-
var getBindings = function getBindings(questionnaire) {
|
|
1007
|
-
var variables = questionnaire.variables;
|
|
1008
|
-
return _objectSpread2(_objectSpread2(_objectSpread2({}, getCollectedStateByValueType(questionnaire)('COLLECTED', true)), getCalculatedFromVariables(variables)), getExternalFromVariables(variables));
|
|
1009
|
-
};
|
|
1010
|
-
|
|
1011
|
-
var filterComponents = function filterComponents(components, management, bindings, features) {
|
|
1012
|
-
var filteredComponents = management ? components : components.filter(function (_ref) {
|
|
1013
|
-
var conditionFilter = _ref.conditionFilter;
|
|
1014
|
-
return !conditionFilter || interpret(features)(bindings, true)(conditionFilter) === 'normal';
|
|
1015
|
-
});
|
|
1016
|
-
return filteredComponents;
|
|
1017
|
-
};
|
|
1018
|
-
|
|
1019
|
-
var useLunatic = function useLunatic(source, data, _ref2) {
|
|
1020
|
-
var _ref2$savingType = _ref2.savingType,
|
|
1021
|
-
savingType = _ref2$savingType === void 0 ? COLLECTED : _ref2$savingType,
|
|
1022
|
-
_ref2$preferences = _ref2.preferences,
|
|
1023
|
-
preferences = _ref2$preferences === void 0 ? [COLLECTED] : _ref2$preferences,
|
|
1024
|
-
_ref2$features = _ref2.features,
|
|
1025
|
-
features = _ref2$features === void 0 ? ['VTL'] : _ref2$features,
|
|
1026
|
-
_ref2$management = _ref2.management,
|
|
1027
|
-
management = _ref2$management === void 0 ? false : _ref2$management;
|
|
1028
|
-
|
|
1029
|
-
var _useState = React.useState(mergeQuestionnaireAndData(source)(data || {})),
|
|
1030
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
1031
|
-
questionnaire = _useState2[0],
|
|
1032
|
-
setQuestionnaire = _useState2[1];
|
|
1033
|
-
|
|
1034
|
-
var _useState3 = React.useState({}),
|
|
1035
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
1036
|
-
todo = _useState4[0],
|
|
1037
|
-
setTodo = _useState4[1];
|
|
1038
|
-
|
|
1039
|
-
var handleChange = React.useCallback(function (updatedValue) {
|
|
1040
|
-
setTodo(updatedValue);
|
|
1041
|
-
}, []); // Assume we only want to handle source update
|
|
1042
|
-
|
|
1043
|
-
React.useEffect(function () {
|
|
1044
|
-
setQuestionnaire(mergeQuestionnaireAndData(source)(data)); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1045
|
-
}, [source]);
|
|
1046
|
-
React.useEffect(function () {
|
|
1047
|
-
if (Object.keys(todo).length !== 0) {
|
|
1048
|
-
var newQ = updateQuestionnaire(savingType)(questionnaire)(preferences)(todo);
|
|
1049
|
-
setQuestionnaire(newQ);
|
|
1050
|
-
setTodo({});
|
|
1051
|
-
}
|
|
1052
|
-
}, [todo, preferences, questionnaire, savingType, features, management]);
|
|
1053
|
-
var bindings = getBindings(questionnaire);
|
|
1054
|
-
var components = filterComponents(questionnaire.components, management, bindings, features);
|
|
1055
|
-
return {
|
|
1056
|
-
questionnaire: questionnaire,
|
|
1057
|
-
handleChange: handleChange,
|
|
1058
|
-
components: components,
|
|
1059
|
-
bindings: bindings
|
|
1060
|
-
};
|
|
1061
|
-
};
|
|
1062
|
-
|
|
1063
|
-
var css_248z$2 = "@charset \"UTF-8\";\n.declaration-instruction {\n font-style: italic;\n font-size: 80%;\n}\n\n.declaration-comment {\n font-size: 80%;\n}\n\n.declaration-statement {\n font-style: italic;\n font-size: 80%;\n color: blue;\n}\n\n.declaration-help {\n font-style: italic;\n font-size: 80%;\n color: green;\n}\n\n.declaration-warning {\n font-style: bold;\n font-size: 80%;\n color: red;\n}\n\n.declaration-message_filter {\n font-size: 100%;\n color: #494242;\n}\n.declaration-message_filter:before {\n content: \"→ \";\n}";
|
|
1064
|
-
styleInject(css_248z$2);
|
|
1065
|
-
|
|
1066
|
-
var Declarations = function Declarations(_ref) {
|
|
1067
|
-
var id = _ref.id,
|
|
1068
|
-
type = _ref.type,
|
|
1069
|
-
declarations = _ref.declarations,
|
|
1070
|
-
features = _ref.features,
|
|
1071
|
-
bindings = _ref.bindings;
|
|
1072
|
-
var filtered = declarations.filter(function (_ref2) {
|
|
1073
|
-
var position = _ref2.position;
|
|
1074
|
-
return position === type;
|
|
1075
|
-
});
|
|
1076
|
-
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1077
|
-
id: "declarations-".concat(id, "-").concat(type),
|
|
1078
|
-
className: "declarations-lunatic"
|
|
1079
|
-
}, filtered.map(function (_ref3) {
|
|
1080
|
-
var idD = _ref3.id,
|
|
1081
|
-
label = _ref3.label,
|
|
1082
|
-
declarationType = _ref3.declarationType;
|
|
1083
|
-
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1084
|
-
key: "".concat(idD),
|
|
1085
|
-
className: "declaration-lunatic declaration-".concat(declarationType.toLowerCase())
|
|
1086
|
-
}, interpret(features)(bindings)(label));
|
|
1087
|
-
}));
|
|
1088
|
-
};
|
|
1089
|
-
|
|
1090
|
-
Declarations.defaultProps = {
|
|
1091
|
-
type: 'AFTER_QUESTION_TEXT',
|
|
1092
|
-
declarations: [],
|
|
1093
|
-
features: [],
|
|
1094
|
-
bindings: {}
|
|
1095
|
-
};
|
|
1096
|
-
Declarations.propTypes = {
|
|
1097
|
-
id: PropTypes__default['default'].string.isRequired,
|
|
1098
|
-
type: PropTypes__default['default'].string,
|
|
1099
|
-
declarations: declarations,
|
|
1100
|
-
features: PropTypes__default['default'].arrayOf(PropTypes__default['default'].string),
|
|
1101
|
-
bindings: PropTypes__default['default'].object
|
|
1102
|
-
};
|
|
1103
|
-
|
|
1104
|
-
var img = new Image(); img.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAYAAADE6YVjAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAMPSURBVEhLrZVdSBRRFMePs36vubp+JJul1pYKEdESlRShL9aDFFZsEEgGBUIvRQ8R9VhEBL0IQUEPPVQWSJBgYil9ET1YVARhqemappmlu4vf2vzPzp3uzoyjVj8Y7syZufO/556PGzOnQja0fR+j+o4gfR6ZVK8JzUqUnRRLK1Pi6HBxGpXkJGtWa+YVqfs0QmdfDVJ4alazzI8zTqEzvkyqLk7XLNGYREYnZ6n0fhf1h6d5cmq8QvvWuKh8lZNc8Q72YHBsmkYmZ6ipJ0yPAiH6+DPiIb5vrMgjryuenwVRItiS3Q+69dVf2Z5D/rUuvrdD9hpCd8pzyZeVpL2VROCB724Hf1iUnkDXSj2mFdmB+Udb++hZX5ifn1YW6PN1EQhgi3Z4nFSnruRvOaYKNXwJUoIjhrqq1rGNReDuieff2CCvwEhrb5hOvxygQGhKs0RAlp3cmKFvrVjw8Q0ZnBAKjJfeDPHLc5uzLAXw8y33OulQc69JAMAGccHlkhwer38Y5lFBHYhMqlnvZqMMBGqe9Fv+XEZOkNJcJ2/7xMwcJ0UsCg1Y5bgQGFXTVaaqKI0ubluuPVlTuXoZJ0F9Z5CU16onYFNmIo8yiJMsgJ/3VRcuKAB82ZEURpdQUFjAm2aOhXgHFrN6GRFbhIIDD1DJdixFwIguIq/6f6OLoBfZgSxZCmhRAFmriDaNZmcEVStAHSxFqG1QSyi1h8W0BEJzKDL0q5a9+fxCUPvuB11oixSqHcaKB6K9nN+aTQoKBy6hXT/sDmmfRBBtYSGMFY8ChwDAMcExET860vKVhsejY7NYIdmLioYeHlHgOI/0Llxws53bwL924VMvBuhW+y++R+ECPbua9+RzoNEK/E29Jo8WA+InBG6UreARRJ2M2Mv9jQH2CODDXXkpfG8H5h1UFyZOVOO8KBGA/PY3BbgdAGTdAW8qlXmSqdD9p7/B02b1fH8cCFJDdyT9sRNXd3pMCzOJABylte+H9fNAeGYHgox0tcJSRAYFeFu93g6Nm8SEl36vi9yJDs1qhOg33VaTt51lxw8AAAAASUVORK5CYII=';
|
|
1105
|
-
|
|
1106
|
-
var img$1 = new Image(); img$1.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABkAAAAZCAMAAAGEMEXHAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAABjUExURf///8Xn9XrH6Va44zKp3Eiy4GW+5b7j9Kja8Bme2CSj2p7W7vH5/UGv34XM69vw+czq9iCh2ZbT7bfg82W94+33/Njt92zB5k+14XPE6On2+4vN6sLl9Mno9i+n3Cum2wAAAIfAWccAAAAhdFJOU///////////////////////////////////////////AJ/B0CEAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAEVSURBVChTVVIBcsMgDFODm2JKIFnTbvv/Ryfb0F11Z4ptWYBSYL8wFBk34A7kLwDCUIbBfkcIHppsM2tIVy61exRoQ0LFaa2NhLSiP7l/MA7no6rsdd+UI5SINQSvZKVsBXSB7N4plnFRyihxxrFdtxeep5qwYRFZx1ZK6735IMrmJSQOZR9sXKWZSKeaVdQVfftOirdG8kHjhXlFxZ0ZWezpwrclo4Q69ZUWZj28BPyobmbCQPYxR6HdE53leLyBpGIGEELHP7GGtB/DIyds+mathZ/BEBefyNSRMJxDwRggcXbMlSlGsPM9uWHpgKnRgPB/zBCd/yStLB3z1hK6wO+8zn7o+7sx47v/s9oOdgdoLAD8AWlNC8M57XWRAAAAAElFTkSuQmCC';
|
|
1107
|
-
|
|
1108
|
-
var img$2 = new Image(); img$2.src = 'data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABwAAAAZCAMAAAFiGY6DAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAABUUExURf///6zc8Uiy4PH5/d/x+b7j9Bme2DKp3CSj2la442W+5YnN61O34nrH6Z7W7tDr9yCh2bfg8+33/HPE6EGv35bT7U+14czq9nDD56XZ7+n2+wAAAJWny4EAAAAcdFJOU////////////////////////////////////wAXsuLXAAAACXBIWXMAAA7EAAAOxAGVKw4bAAABKElEQVQoU2VSC3bDIAwzJRM0hCb0ldfd/6STDFm7TgnEX2GbGHExQ4PZoc0scT0MgC/6xkqZ+tC0x6y4E4zlU5VAs8I2Wrv0/PL/xzih4gKsCJVB1RZKsvXYrJntG7gXrM/ddgZ3JPDtBRHFSQYG1Ylgy9cUhStwdaGKO6tAdX0wCQi5tUyzK6oYYNHB+aDDBXhHcjtu09uHKgfTYGTUXMRDtCOU7HUU8ShH1CdWdj1FoS/3k+4vyB3Se6KV8tv6Bamm2Z3d+GWvuNmel4WC7A9+OUcV9AKr5PHEJHIxavjui4mOisf0/B7uiqwTrp9/gisa0wuycLTs3zlI2yl7QpTvDR8FlXy3jWq3hqBYjYpXPy/A7Lmu33GIMR1r3z6OPnFngYFXbfYDTw4LkdQNpj4AAAAASUVORK5CYII=';
|
|
1109
|
-
|
|
1110
|
-
var img$3 = /*#__PURE__*/Object.freeze({
|
|
1111
|
-
__proto__: null,
|
|
1112
|
-
collectedImg: img,
|
|
1113
|
-
editedImg: img$1,
|
|
1114
|
-
forcedImg: img$2
|
|
1115
|
-
});
|
|
1116
|
-
|
|
1117
|
-
var css_248z$3 = "* {\n box-sizing: border-box;\n}\n\n.mandatory:after {\n content: \" *\";\n color: red;\n}\n\n.horizontal-options {\n display: inline-block;\n margin-right: 2em;\n}\n\nlabel,\n.lunatic-dropdown-label {\n margin-bottom: 0.5em;\n}\n\n.label-top {\n display: flex;\n flex-direction: column;\n}\n\n.label-bottom {\n display: flex;\n flex-direction: column-reverse;\n}\n\n.label-right {\n justify-content: flex-end;\n display: flex;\n flex-direction: row-reverse;\n align-items: baseline;\n}\n.label-right :first-child {\n margin-right: 1rem;\n}\n\n.label-left {\n display: flex;\n flex-direction: row;\n align-items: baseline;\n}\n.label-left :first-child {\n margin-right: 1rem;\n}\n\n.field-container {\n display: flex;\n}\n\n.tooltip {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n.field-with-tooltip {\n width: calc(100% - 25px);\n position: relative;\n}\n\n.field {\n width: 100%;\n position: relative;\n}\n\n/* Tooltip container */\n.tooltip-lunatic {\n position: relative;\n display: inline-block;\n align-items: center;\n}\n\n/* Tooltip text */\n.tooltip-lunatic .tooltip-text {\n visibility: hidden;\n width: 20em;\n background-color: #e80a4d;\n color: #fff;\n padding: 5px 0;\n border-radius: 6px;\n text-align: left;\n /* Position the tooltip text */\n position: absolute;\n z-index: 1;\n bottom: 120%;\n left: -10em;\n /* Fade in tooltip */\n opacity: 0;\n transition: opacity 0.3s;\n}\n\n/* Show the tooltip text when you mouse over the tooltip container */\n.tooltip-lunatic:hover .tooltip-text {\n visibility: visible;\n opacity: 1;\n}";
|
|
1118
|
-
styleInject(css_248z$3);
|
|
1119
|
-
|
|
1120
|
-
var TooltipResponse = function TooltipResponse(_ref) {
|
|
1121
|
-
var id = _ref.id,
|
|
1122
|
-
response = _ref.response;
|
|
1123
|
-
|
|
1124
|
-
var _useState = React.useState(function () {
|
|
1125
|
-
return buildTooltip(response);
|
|
1126
|
-
}),
|
|
1127
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
1128
|
-
tooltipElements = _useState2[0],
|
|
1129
|
-
setTooltipElements = _useState2[1];
|
|
1130
|
-
|
|
1131
|
-
React.useEffect(function () {
|
|
1132
|
-
setTooltipElements(buildTooltip(response));
|
|
1133
|
-
}, [response]);
|
|
1134
|
-
var content = tooltipElements.content,
|
|
1135
|
-
imgName = tooltipElements.imgName;
|
|
1136
|
-
if (!content) return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1137
|
-
className: "tooltip-lunatic"
|
|
1138
|
-
}, /*#__PURE__*/React__default['default'].createElement("img", {
|
|
1139
|
-
id: id,
|
|
1140
|
-
alt: "img-tooltip",
|
|
1141
|
-
src: img.src || img
|
|
1142
|
-
}));
|
|
1143
|
-
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1144
|
-
className: "tooltip-lunatic"
|
|
1145
|
-
}, /*#__PURE__*/React__default['default'].createElement("img", {
|
|
1146
|
-
id: id,
|
|
1147
|
-
alt: "img-tooltip",
|
|
1148
|
-
src: img$3[imgName].src || img$3[imgName]
|
|
1149
|
-
}), /*#__PURE__*/React__default['default'].createElement("span", {
|
|
1150
|
-
className: "tooltip-text"
|
|
1151
|
-
}, /*#__PURE__*/React__default['default'].createElement("ul", null, content.map(function (_ref2) {
|
|
1152
|
-
var key = _ref2.key,
|
|
1153
|
-
value = _ref2.value;
|
|
1154
|
-
return /*#__PURE__*/React__default['default'].createElement("li", {
|
|
1155
|
-
key: "tooltip-".concat(id, "-content-").concat(key)
|
|
1156
|
-
}, "".concat(key, " : ").concat(value));
|
|
1157
|
-
}))));
|
|
1158
|
-
};
|
|
1159
|
-
|
|
1160
|
-
TooltipResponse.defaultProps = {
|
|
1161
|
-
response: {}
|
|
1162
|
-
};
|
|
1163
|
-
TooltipResponse.propTypes = {
|
|
1164
|
-
id: PropTypes__default['default'].string,
|
|
1165
|
-
response: response
|
|
1166
|
-
};
|
|
1167
|
-
|
|
1168
|
-
var css_248z$4 = "* {\n box-sizing: border-box;\n}\n\n.mandatory:after {\n content: \" *\";\n color: red;\n}\n\n.horizontal-options {\n display: inline-block;\n margin-right: 2em;\n}\n\nlabel,\n.lunatic-dropdown-label {\n margin-bottom: 0.5em;\n}\n\n.label-top {\n display: flex;\n flex-direction: column;\n}\n\n.label-bottom {\n display: flex;\n flex-direction: column-reverse;\n}\n\n.label-right {\n justify-content: flex-end;\n display: flex;\n flex-direction: row-reverse;\n align-items: baseline;\n}\n.label-right :first-child {\n margin-right: 1rem;\n}\n\n.label-left {\n display: flex;\n flex-direction: row;\n align-items: baseline;\n}\n.label-left :first-child {\n margin-right: 1rem;\n}\n\n.field-container {\n display: flex;\n}\n\n.tooltip {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n.field-with-tooltip {\n width: calc(100% - 25px);\n position: relative;\n}\n\n.field {\n width: 100%;\n position: relative;\n}\n\n.checkbox-group {\n border: 0.1em solid #e80a4d;\n}\n\n.checkbox-lunatic {\n margin: 0;\n margin-right: 1em;\n margin-left: 1em;\n margin-top: 0.5em;\n}\n.checkbox-lunatic:focus {\n outline: none;\n}\n.checkbox-lunatic:checked + label {\n border: 0.1em solid #e80a4d;\n padding: 0.3em;\n}\n.checkbox-lunatic:focus {\n box-shadow: 0 0 0.3em 0.3em #e80a4d;\n}\n\n.checkbox-lunatic-no-margin {\n margin: 0;\n margin-right: 1em;\n margin-left: 0;\n margin-top: 0.5em;\n}\n.checkbox-lunatic-no-margin:focus {\n outline: none;\n}\n.checkbox-lunatic-no-margin:checked + label {\n border: 0.1em solid #e80a4d;\n padding: 0.3em;\n}\n\n.checkbox-modality {\n margin-top: 1em;\n}\n\n.checkbox-boolean-modality {\n margin-top: 1em;\n}\n\n.checkbox-alone {\n margin-left: 0;\n margin-top: 0.5em;\n}";
|
|
1169
|
-
styleInject(css_248z$4);
|
|
1170
|
-
|
|
1171
|
-
var CheckboxGroup = function CheckboxGroup(_ref) {
|
|
1172
|
-
var id = _ref.id,
|
|
1173
|
-
label = _ref.label,
|
|
1174
|
-
preferences = _ref.preferences,
|
|
1175
|
-
responses = _ref.responses,
|
|
1176
|
-
propsHandleChange = _ref.handleChange,
|
|
1177
|
-
disabled = _ref.disabled,
|
|
1178
|
-
focused = _ref.focused,
|
|
1179
|
-
keyboardSelection = _ref.keyboardSelection,
|
|
1180
|
-
positioning = _ref.positioning,
|
|
1181
|
-
declarations = _ref.declarations,
|
|
1182
|
-
features = _ref.features,
|
|
1183
|
-
bindings = _ref.bindings,
|
|
1184
|
-
management = _ref.management,
|
|
1185
|
-
style = _ref.style;
|
|
1186
|
-
var fieldsetStyle = style.fieldsetStyle,
|
|
1187
|
-
modalityStyle = style.modalityStyle;
|
|
1188
|
-
var inputRef = React.useRef();
|
|
1189
|
-
|
|
1190
|
-
var _useState = React.useState(function () {
|
|
1191
|
-
return responses.map(function (_ref2) {
|
|
1192
|
-
var response = _ref2.response;
|
|
1193
|
-
return getResponseByPreference(preferences)(response);
|
|
1194
|
-
});
|
|
1195
|
-
}),
|
|
1196
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
1197
|
-
values = _useState2[0],
|
|
1198
|
-
setValues = _useState2[1];
|
|
1199
|
-
|
|
1200
|
-
var handleChange = debounce__default['default'](function (obj) {
|
|
1201
|
-
return propsHandleChange(obj);
|
|
1202
|
-
}, 50);
|
|
1203
|
-
|
|
1204
|
-
var specificHandleChange = function specificHandleChange(e) {
|
|
1205
|
-
var _Object$entries$ = _slicedToArray(Object.entries(e)[0], 2),
|
|
1206
|
-
key = _Object$entries$[0],
|
|
1207
|
-
value = _Object$entries$[1];
|
|
1208
|
-
|
|
1209
|
-
if (value === false && responsesToClean(responses)(preferences)(key)) handleChange(_defineProperty({}, key, null));else handleChange(e);
|
|
1210
|
-
};
|
|
1211
|
-
|
|
1212
|
-
React.useEffect(function () {
|
|
1213
|
-
if (focused) inputRef.current.focus();
|
|
1214
|
-
}, [focused]);
|
|
1215
|
-
var checkedArray = [];
|
|
1216
|
-
return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
1217
|
-
id: id,
|
|
1218
|
-
type: BEFORE_QUESTION_TEXT,
|
|
1219
|
-
declarations: declarations,
|
|
1220
|
-
features: features,
|
|
1221
|
-
bindings: bindings
|
|
1222
|
-
}), /*#__PURE__*/React__default['default'].createElement("fieldset", {
|
|
1223
|
-
key: "checkbox-".concat(id),
|
|
1224
|
-
className: "checkbox-group",
|
|
1225
|
-
style: buildStyleObject(fieldsetStyle)
|
|
1226
|
-
}, /*#__PURE__*/React__default['default'].createElement("legend", null, interpret(features)(bindings)(label)), /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
1227
|
-
id: id,
|
|
1228
|
-
type: AFTER_QUESTION_TEXT,
|
|
1229
|
-
declarations: declarations,
|
|
1230
|
-
features: features,
|
|
1231
|
-
bindings: bindings
|
|
1232
|
-
}), responses.map(function (_ref3, i) {
|
|
1233
|
-
var modId = _ref3.id,
|
|
1234
|
-
modLabel = _ref3.label,
|
|
1235
|
-
response = _ref3.response;
|
|
1236
|
-
var checked = values[i];
|
|
1237
|
-
if (checked) checkedArray.push(modId);
|
|
1238
|
-
var toRef = i === 0 || checkedArray[0] && checkedArray[0] === modId;
|
|
1239
|
-
var interpretedLabel = interpret(features)(bindings)(modLabel);
|
|
1240
|
-
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1241
|
-
className: "".concat(getItemsPositioningClass(positioning)),
|
|
1242
|
-
key: "checkbox-".concat(id, "-").concat(modId)
|
|
1243
|
-
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1244
|
-
className: "field-container"
|
|
1245
|
-
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1246
|
-
className: "".concat(management ? 'field-with-tooltip' : 'field')
|
|
1247
|
-
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1248
|
-
className: "checkbox-modality ".concat(checked ? 'content-checked' : '')
|
|
1249
|
-
}, /*#__PURE__*/React__default['default'].createElement("input", {
|
|
1250
|
-
type: "checkbox",
|
|
1251
|
-
id: "checkbox-".concat(id, "-").concat(modId),
|
|
1252
|
-
ref: toRef ? inputRef : null,
|
|
1253
|
-
key: "checkbox-".concat(id, "-").concat(modId),
|
|
1254
|
-
"aria-labelledby": "input-label-".concat(id, "-").concat(modId),
|
|
1255
|
-
className: "checkbox-lunatic",
|
|
1256
|
-
checked: checked,
|
|
1257
|
-
disabled: disabled,
|
|
1258
|
-
onChange: function onChange(_ref4) {
|
|
1259
|
-
var checked = _ref4.target.checked;
|
|
1260
|
-
setValues(values.map(function (v, j) {
|
|
1261
|
-
return i === j ? checked : v;
|
|
1262
|
-
}));
|
|
1263
|
-
specificHandleChange(_defineProperty({}, getResponseName(response), checked));
|
|
1264
|
-
}
|
|
1265
|
-
}), /*#__PURE__*/React__default['default'].createElement("label", {
|
|
1266
|
-
htmlFor: "checkbox-".concat(id, "-").concat(modId),
|
|
1267
|
-
id: "input-label-".concat(id, "-").concat(modId),
|
|
1268
|
-
style: checked ? buildStyleObject(modalityStyle) : {}
|
|
1269
|
-
}, keyboardSelection && /*#__PURE__*/React__default['default'].createElement("span", {
|
|
1270
|
-
className: "code-modality"
|
|
1271
|
-
}, responses.length < 10 ? i + 1 : getAlphabet()[i].toUpperCase()), interpretedLabel))), management && /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1272
|
-
className: "tooltip"
|
|
1273
|
-
}, /*#__PURE__*/React__default['default'].createElement(TooltipResponse, {
|
|
1274
|
-
id: id,
|
|
1275
|
-
response: buildBooleanTooltipResponse(response)
|
|
1276
|
-
}))));
|
|
1277
|
-
})), /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
1278
|
-
id: id,
|
|
1279
|
-
type: DETACHABLE,
|
|
1280
|
-
declarations: declarations,
|
|
1281
|
-
features: features,
|
|
1282
|
-
bindings: bindings
|
|
1283
|
-
}));
|
|
1284
|
-
};
|
|
1285
|
-
|
|
1286
|
-
CheckboxGroup.defaultProps = {
|
|
1287
|
-
label: '',
|
|
1288
|
-
preferences: ['COLLECTED'],
|
|
1289
|
-
responses: [],
|
|
1290
|
-
disabled: false,
|
|
1291
|
-
focused: false,
|
|
1292
|
-
keyboardSelection: false,
|
|
1293
|
-
positioning: 'DEFAULT',
|
|
1294
|
-
declarations: [],
|
|
1295
|
-
features: [],
|
|
1296
|
-
bindings: {},
|
|
1297
|
-
management: false,
|
|
1298
|
-
style: {
|
|
1299
|
-
fieldsetStyle: {},
|
|
1300
|
-
modalityStyle: {}
|
|
1301
|
-
}
|
|
1302
|
-
};
|
|
1303
|
-
CheckboxGroup.propTypes = {
|
|
1304
|
-
id: PropTypes__default['default'].string.isRequired,
|
|
1305
|
-
label: PropTypes__default['default'].string,
|
|
1306
|
-
preferences: PropTypes__default['default'].arrayOf(valueType),
|
|
1307
|
-
response: response,
|
|
1308
|
-
handleChange: PropTypes__default['default'].func.isRequired,
|
|
1309
|
-
disabled: PropTypes__default['default'].bool,
|
|
1310
|
-
focused: PropTypes__default['default'].bool,
|
|
1311
|
-
keyboardSelection: PropTypes__default['default'].bool,
|
|
1312
|
-
positioning: PropTypes__default['default'].oneOf(['DEFAULT', 'HORIZONTAL', 'VERTICAL']),
|
|
1313
|
-
declarations: declarations,
|
|
1314
|
-
features: PropTypes__default['default'].arrayOf(PropTypes__default['default'].string),
|
|
1315
|
-
bindings: PropTypes__default['default'].object,
|
|
1316
|
-
management: PropTypes__default['default'].bool,
|
|
1317
|
-
style: PropTypes__default['default'].object
|
|
1318
|
-
};
|
|
1319
|
-
var group = /*#__PURE__*/React__default['default'].memo(CheckboxGroup, areEqual);
|
|
1320
|
-
|
|
1321
|
-
var CheckboxBoolean = function CheckboxBoolean(_ref) {
|
|
1322
|
-
var id = _ref.id,
|
|
1323
|
-
label = _ref.label,
|
|
1324
|
-
preferences = _ref.preferences,
|
|
1325
|
-
response = _ref.response,
|
|
1326
|
-
propsHandleChange = _ref.handleChange,
|
|
1327
|
-
disabled = _ref.disabled,
|
|
1328
|
-
positioning = _ref.positioning,
|
|
1329
|
-
focused = _ref.focused,
|
|
1330
|
-
declarations = _ref.declarations,
|
|
1331
|
-
features = _ref.features,
|
|
1332
|
-
bindings = _ref.bindings,
|
|
1333
|
-
management = _ref.management,
|
|
1334
|
-
style = _ref.style;
|
|
1335
|
-
var inputRef = React.useRef();
|
|
1336
|
-
|
|
1337
|
-
var _useState = React.useState(function () {
|
|
1338
|
-
return getResponseByPreference(preferences)(response);
|
|
1339
|
-
}),
|
|
1340
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
1341
|
-
value = _useState2[0],
|
|
1342
|
-
setValue = _useState2[1];
|
|
1343
|
-
|
|
1344
|
-
var handleChange = debounce__default['default'](function (obj) {
|
|
1345
|
-
return propsHandleChange(obj);
|
|
1346
|
-
}, 50);
|
|
1347
|
-
|
|
1348
|
-
var specificHandleChange = function specificHandleChange(e) {
|
|
1349
|
-
var _Object$entries$ = _slicedToArray(Object.entries(e)[0], 2),
|
|
1350
|
-
key = _Object$entries$[0],
|
|
1351
|
-
value = _Object$entries$[1];
|
|
1352
|
-
|
|
1353
|
-
if (value === false && responseToClean(response)(preferences)) handleChange(_defineProperty({}, key, null));else handleChange(e);
|
|
1354
|
-
};
|
|
1355
|
-
|
|
1356
|
-
React.useEffect(function () {
|
|
1357
|
-
if (focused) inputRef.current.focus();
|
|
1358
|
-
}, [focused]);
|
|
1359
|
-
var isVertical = positioning === 'VERTICAL';
|
|
1360
|
-
var isHorizontal = positioning === 'HORIZONTAL';
|
|
1361
|
-
var input = /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement("input", {
|
|
1362
|
-
type: "checkbox",
|
|
1363
|
-
id: "checkbox-boolean-".concat(id),
|
|
1364
|
-
ref: inputRef,
|
|
1365
|
-
title: label ? label : 'empty-label',
|
|
1366
|
-
className: "checkbox-boolean-lunatic".concat(isVertical ? '-no-margin' : ''),
|
|
1367
|
-
style: buildStyleObject(style),
|
|
1368
|
-
checked: value,
|
|
1369
|
-
disabled: disabled,
|
|
1370
|
-
onChange: function onChange(_ref2) {
|
|
1371
|
-
var checked = _ref2.target.checked;
|
|
1372
|
-
setValue(checked);
|
|
1373
|
-
specificHandleChange(_defineProperty({}, getResponseName(response), checked));
|
|
1374
|
-
}
|
|
1375
|
-
}), label && /*#__PURE__*/React__default['default'].createElement("label", {
|
|
1376
|
-
htmlFor: "checkbox-boolean-".concat(id)
|
|
1377
|
-
}, isHorizontal ? interpret(features)(bindings)(label) : ''));
|
|
1378
|
-
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1379
|
-
key: "checkbox-boolean-".concat(id),
|
|
1380
|
-
className: "checkbox-boolean-modality"
|
|
1381
|
-
}, /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
1382
|
-
id: id,
|
|
1383
|
-
type: BEFORE_QUESTION_TEXT,
|
|
1384
|
-
declarations: declarations,
|
|
1385
|
-
features: features,
|
|
1386
|
-
bindings: bindings
|
|
1387
|
-
}), label && !isHorizontal && /*#__PURE__*/React__default['default'].createElement("label", {
|
|
1388
|
-
htmlFor: "checkbox-boolean-".concat(id)
|
|
1389
|
-
}, interpret(features)(bindings)(label)), /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
1390
|
-
id: id,
|
|
1391
|
-
type: AFTER_QUESTION_TEXT,
|
|
1392
|
-
declarations: declarations,
|
|
1393
|
-
features: features,
|
|
1394
|
-
bindings: bindings
|
|
1395
|
-
}), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1396
|
-
className: "field-container"
|
|
1397
|
-
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1398
|
-
className: "".concat(management ? 'field-with-tooltip' : 'field')
|
|
1399
|
-
}, isVertical ? /*#__PURE__*/React__default['default'].createElement("div", null, input) : input), management && /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1400
|
-
className: "tooltip"
|
|
1401
|
-
}, /*#__PURE__*/React__default['default'].createElement(TooltipResponse, {
|
|
1402
|
-
id: id,
|
|
1403
|
-
response: buildBooleanTooltipResponse(response)
|
|
1404
|
-
}))), /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
1405
|
-
id: id,
|
|
1406
|
-
type: DETACHABLE,
|
|
1407
|
-
declarations: declarations,
|
|
1408
|
-
features: features,
|
|
1409
|
-
bindings: bindings
|
|
1410
|
-
}));
|
|
1411
|
-
};
|
|
1412
|
-
|
|
1413
|
-
CheckboxBoolean.defaultProps = {
|
|
1414
|
-
label: '',
|
|
1415
|
-
preferences: ['COLLECTED'],
|
|
1416
|
-
response: {},
|
|
1417
|
-
disabled: false,
|
|
1418
|
-
positioning: 'DEFAULT',
|
|
1419
|
-
focused: false,
|
|
1420
|
-
declarations: [],
|
|
1421
|
-
features: [],
|
|
1422
|
-
bindings: {},
|
|
1423
|
-
management: false,
|
|
1424
|
-
style: {}
|
|
1425
|
-
};
|
|
1426
|
-
CheckboxBoolean.propTypes = {
|
|
1427
|
-
id: PropTypes__default['default'].string.isRequired,
|
|
1428
|
-
label: PropTypes__default['default'].string,
|
|
1429
|
-
preferences: PropTypes__default['default'].arrayOf(valueType),
|
|
1430
|
-
response: response,
|
|
1431
|
-
handleChange: PropTypes__default['default'].func.isRequired,
|
|
1432
|
-
disabled: PropTypes__default['default'].bool,
|
|
1433
|
-
positioning: PropTypes__default['default'].oneOf(['DEFAULT', 'HORIZONTAL', 'VERTICAL']),
|
|
1434
|
-
focused: PropTypes__default['default'].bool,
|
|
1435
|
-
declarations: declarations,
|
|
1436
|
-
features: PropTypes__default['default'].arrayOf(PropTypes__default['default'].string),
|
|
1437
|
-
bindings: PropTypes__default['default'].object,
|
|
1438
|
-
management: PropTypes__default['default'].bool,
|
|
1439
|
-
style: PropTypes__default['default'].object
|
|
1440
|
-
};
|
|
1441
|
-
var boolean = /*#__PURE__*/React__default['default'].memo(CheckboxBoolean, areEqual);
|
|
1442
|
-
|
|
1443
|
-
var InputDeclarationsWrapper = function InputDeclarationsWrapper(_ref) {
|
|
1444
|
-
var id = _ref.id,
|
|
1445
|
-
label = _ref.label,
|
|
1446
|
-
preferences = _ref.preferences,
|
|
1447
|
-
response = _ref.response,
|
|
1448
|
-
placeholder = _ref.placeholder,
|
|
1449
|
-
handleChange = _ref.handleChange,
|
|
1450
|
-
maxLength = _ref.maxLength,
|
|
1451
|
-
readOnly = _ref.readOnly,
|
|
1452
|
-
disabled = _ref.disabled,
|
|
1453
|
-
autoComplete = _ref.autoComplete,
|
|
1454
|
-
labelPosition = _ref.labelPosition,
|
|
1455
|
-
mandatory = _ref.mandatory,
|
|
1456
|
-
declarations = _ref.declarations,
|
|
1457
|
-
features = _ref.features,
|
|
1458
|
-
bindings = _ref.bindings,
|
|
1459
|
-
focused = _ref.focused,
|
|
1460
|
-
management = _ref.management,
|
|
1461
|
-
style = _ref.style,
|
|
1462
|
-
type = _ref.type,
|
|
1463
|
-
roleType = _ref.roleType;
|
|
1464
|
-
var inputRef = React.useRef();
|
|
1465
|
-
|
|
1466
|
-
var _useState = React.useState(function () {
|
|
1467
|
-
return getResponseByPreference(preferences)(response);
|
|
1468
|
-
}),
|
|
1469
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
1470
|
-
value = _useState2[0],
|
|
1471
|
-
setValue = _useState2[1];
|
|
1472
|
-
|
|
1473
|
-
React.useEffect(function () {
|
|
1474
|
-
if (focused) inputRef.current.focus();
|
|
1475
|
-
}, [focused]); // Assume we only want to handle enable external updates
|
|
1476
|
-
// Don't need to check all value changes
|
|
1477
|
-
|
|
1478
|
-
React.useEffect(function () {
|
|
1479
|
-
if (getResponseByPreference(preferences)(response) !== value) setValue(getResponseByPreference(preferences)(response)); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
1480
|
-
}, [response, preferences]);
|
|
1481
|
-
|
|
1482
|
-
var handleChangeOnBlur = function handleChangeOnBlur() {
|
|
1483
|
-
handleChange(_defineProperty({}, getResponseName(response), value));
|
|
1484
|
-
};
|
|
1485
|
-
|
|
1486
|
-
var Component = roleType === 'textarea' ? 'textarea' : 'input';
|
|
1487
|
-
return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
1488
|
-
id: id,
|
|
1489
|
-
type: BEFORE_QUESTION_TEXT,
|
|
1490
|
-
declarations: declarations,
|
|
1491
|
-
features: features,
|
|
1492
|
-
bindings: bindings
|
|
1493
|
-
}), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1494
|
-
className: getLabelPositionClass(labelPosition)
|
|
1495
|
-
}, label && /*#__PURE__*/React__default['default'].createElement("label", {
|
|
1496
|
-
htmlFor: "".concat(roleType, "-").concat(id),
|
|
1497
|
-
id: "".concat(roleType, "-label-").concat(id),
|
|
1498
|
-
className: "".concat(mandatory ? 'mandatory' : '')
|
|
1499
|
-
}, interpret(features)(bindings)(label)), /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
1500
|
-
id: id,
|
|
1501
|
-
type: AFTER_QUESTION_TEXT,
|
|
1502
|
-
declarations: declarations,
|
|
1503
|
-
features: features,
|
|
1504
|
-
bindings: bindings
|
|
1505
|
-
}), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1506
|
-
className: "field-container"
|
|
1507
|
-
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1508
|
-
className: "".concat(management ? 'field-with-tooltip' : 'field')
|
|
1509
|
-
}, /*#__PURE__*/React__default['default'].createElement(Component, {
|
|
1510
|
-
type: type,
|
|
1511
|
-
id: "".concat(roleType, "-").concat(id),
|
|
1512
|
-
ref: inputRef,
|
|
1513
|
-
value: value,
|
|
1514
|
-
placeholder: placeholder,
|
|
1515
|
-
autoComplete: autoComplete ? 'on' : 'off',
|
|
1516
|
-
className: "".concat(roleType, "-lunatic"),
|
|
1517
|
-
style: buildStyleObject(style),
|
|
1518
|
-
readOnly: readOnly,
|
|
1519
|
-
disabled: disabled,
|
|
1520
|
-
maxLength: maxLength || 524288,
|
|
1521
|
-
required: mandatory,
|
|
1522
|
-
"aria-required": mandatory,
|
|
1523
|
-
onChange: function onChange(_ref2) {
|
|
1524
|
-
var v = _ref2.target.value;
|
|
1525
|
-
if (management) setValue(v);else setValue(v === '' ? null : v);
|
|
1526
|
-
},
|
|
1527
|
-
onBlur: handleChangeOnBlur
|
|
1528
|
-
})), management && /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1529
|
-
className: "tooltip"
|
|
1530
|
-
}, /*#__PURE__*/React__default['default'].createElement(TooltipResponse, {
|
|
1531
|
-
id: id,
|
|
1532
|
-
response: buildLocalResponse(response, value)
|
|
1533
|
-
})))), /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
1534
|
-
id: id,
|
|
1535
|
-
type: DETACHABLE,
|
|
1536
|
-
declarations: declarations,
|
|
1537
|
-
features: features,
|
|
1538
|
-
bindings: bindings
|
|
1539
|
-
}));
|
|
1540
|
-
};
|
|
1541
|
-
|
|
1542
|
-
InputDeclarationsWrapper.defaultProps = {
|
|
1543
|
-
label: '',
|
|
1544
|
-
preferences: ['COLLECTED'],
|
|
1545
|
-
response: {},
|
|
1546
|
-
placeholder: '',
|
|
1547
|
-
readOnly: false,
|
|
1548
|
-
disabled: false,
|
|
1549
|
-
autoComplete: false,
|
|
1550
|
-
labelPosition: 'DEFAULT',
|
|
1551
|
-
mandatory: false,
|
|
1552
|
-
focused: false,
|
|
1553
|
-
declarations: [],
|
|
1554
|
-
features: [],
|
|
1555
|
-
bindings: {},
|
|
1556
|
-
management: false,
|
|
1557
|
-
style: {}
|
|
1558
|
-
};
|
|
1559
|
-
InputDeclarationsWrapper.propTypes = {
|
|
1560
|
-
id: PropTypes__default['default'].string.isRequired,
|
|
1561
|
-
label: PropTypes__default['default'].string,
|
|
1562
|
-
preferences: PropTypes__default['default'].arrayOf(valueType),
|
|
1563
|
-
response: response,
|
|
1564
|
-
placeholder: PropTypes__default['default'].string,
|
|
1565
|
-
handleChange: PropTypes__default['default'].func.isRequired,
|
|
1566
|
-
readOnly: PropTypes__default['default'].bool,
|
|
1567
|
-
disabled: PropTypes__default['default'].bool,
|
|
1568
|
-
maxLength: PropTypes__default['default'].oneOfType([PropTypes__default['default'].number, PropTypes__default['default'].string]),
|
|
1569
|
-
autoComplete: PropTypes__default['default'].bool,
|
|
1570
|
-
labelPosition: PropTypes__default['default'].oneOf(['DEFAULT', 'TOP', 'BOTTOM', 'LEFT', 'RIGHT']),
|
|
1571
|
-
mandatory: PropTypes__default['default'].bool,
|
|
1572
|
-
focused: PropTypes__default['default'].bool,
|
|
1573
|
-
declarations: declarations,
|
|
1574
|
-
features: PropTypes__default['default'].arrayOf(PropTypes__default['default'].string),
|
|
1575
|
-
bindings: PropTypes__default['default'].object,
|
|
1576
|
-
management: PropTypes__default['default'].bool,
|
|
1577
|
-
style: PropTypes__default['default'].object,
|
|
1578
|
-
type: PropTypes__default['default'].oneOf(['text', 'date', null]),
|
|
1579
|
-
roleType: PropTypes__default['default'].oneOf(['input', 'datepicker', 'textarea'])
|
|
1580
|
-
};
|
|
1581
|
-
|
|
1582
|
-
var ListDeclarationsWrapper = function ListDeclarationsWrapper(_ref) {
|
|
1583
|
-
var id = _ref.id,
|
|
1584
|
-
label = _ref.label,
|
|
1585
|
-
preferences = _ref.preferences,
|
|
1586
|
-
response = _ref.response,
|
|
1587
|
-
options = _ref.options,
|
|
1588
|
-
propsHandleChange = _ref.handleChange,
|
|
1589
|
-
disabled = _ref.disabled,
|
|
1590
|
-
focused = _ref.focused,
|
|
1591
|
-
keyboardSelection = _ref.keyboardSelection,
|
|
1592
|
-
declarations = _ref.declarations,
|
|
1593
|
-
features = _ref.features,
|
|
1594
|
-
bindings = _ref.bindings,
|
|
1595
|
-
management = _ref.management,
|
|
1596
|
-
style = _ref.style,
|
|
1597
|
-
positioning = _ref.positioning,
|
|
1598
|
-
type = _ref.type,
|
|
1599
|
-
hasSpecificHandler = _ref.hasSpecificHandler;
|
|
1600
|
-
var inputRef = React.useRef();
|
|
1601
|
-
|
|
1602
|
-
var _useState = React.useState(function () {
|
|
1603
|
-
return getResponseByPreference(preferences)(response);
|
|
1604
|
-
}),
|
|
1605
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
1606
|
-
value = _useState2[0],
|
|
1607
|
-
setValue = _useState2[1];
|
|
1608
|
-
|
|
1609
|
-
var specificHandleChange = function specificHandleChange(e) {
|
|
1610
|
-
var values = response.values;
|
|
1611
|
-
|
|
1612
|
-
var _Object$entries$ = _slicedToArray(Object.entries(e)[0], 2),
|
|
1613
|
-
key = _Object$entries$[0],
|
|
1614
|
-
value = _Object$entries$[1];
|
|
1615
|
-
|
|
1616
|
-
var newValue = values[preferences[preferences.length - 1]] === value ? null : value;
|
|
1617
|
-
handleChange(_defineProperty({}, key, newValue));
|
|
1618
|
-
|
|
1619
|
-
if (management) {
|
|
1620
|
-
setValue(getResponseByPreference(preferences)(buildLocalResponse(response, newValue)));
|
|
1621
|
-
} else setValue(newValue);
|
|
1622
|
-
};
|
|
1623
|
-
|
|
1624
|
-
var handleChange = debounce__default['default'](function (obj) {
|
|
1625
|
-
return propsHandleChange(obj);
|
|
1626
|
-
}, 50);
|
|
1627
|
-
|
|
1628
|
-
var _onChange = function onChange(v) {
|
|
1629
|
-
var update = _defineProperty({}, getResponseName(response), v);
|
|
1630
|
-
|
|
1631
|
-
if (hasSpecificHandler) specificHandleChange(update);else {
|
|
1632
|
-
setValue(v);
|
|
1633
|
-
handleChange(update);
|
|
1634
|
-
}
|
|
1635
|
-
};
|
|
1636
|
-
|
|
1637
|
-
React.useEffect(function () {
|
|
1638
|
-
if (focused) inputRef.current.focus();
|
|
1639
|
-
}, [focused]);
|
|
1640
|
-
var fieldsetStyle = style.fieldsetStyle,
|
|
1641
|
-
modalityStyle = style.modalityStyle;
|
|
1642
|
-
return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
1643
|
-
id: id,
|
|
1644
|
-
type: BEFORE_QUESTION_TEXT,
|
|
1645
|
-
declarations: declarations,
|
|
1646
|
-
features: features,
|
|
1647
|
-
bindings: bindings
|
|
1648
|
-
}), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1649
|
-
className: "field-container"
|
|
1650
|
-
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1651
|
-
className: "".concat(management ? 'field-with-tooltip' : 'field')
|
|
1652
|
-
}, /*#__PURE__*/React__default['default'].createElement("fieldset", {
|
|
1653
|
-
key: "".concat(type, "-").concat(id),
|
|
1654
|
-
className: "".concat(type, "-group"),
|
|
1655
|
-
style: buildStyleObject(fieldsetStyle)
|
|
1656
|
-
}, /*#__PURE__*/React__default['default'].createElement("legend", null, interpret(features)(bindings)(label)), /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
1657
|
-
id: id,
|
|
1658
|
-
type: AFTER_QUESTION_TEXT,
|
|
1659
|
-
declarations: declarations,
|
|
1660
|
-
features: features,
|
|
1661
|
-
bindings: bindings
|
|
1662
|
-
}), options.map(function (_ref2, i) {
|
|
1663
|
-
var optionLabel = _ref2.label,
|
|
1664
|
-
optionValue = _ref2.value;
|
|
1665
|
-
var checked = value === optionValue;
|
|
1666
|
-
var interpretedLabel = interpret(features)(bindings)(optionLabel);
|
|
1667
|
-
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1668
|
-
key: "".concat(type, "-").concat(id, "-").concat(optionValue),
|
|
1669
|
-
className: "".concat(type, "-modality ").concat(getItemsPositioningClass(positioning), " ").concat(checked ? 'content-checked' : '')
|
|
1670
|
-
}, /*#__PURE__*/React__default['default'].createElement("input", {
|
|
1671
|
-
type: type,
|
|
1672
|
-
name: "".concat(type, "-").concat(id),
|
|
1673
|
-
ref: i === 0 || checked ? inputRef : null,
|
|
1674
|
-
id: "".concat(type, "-").concat(id, "-").concat(optionValue),
|
|
1675
|
-
"aria-labelledby": "input-label-".concat(id, "-").concat(optionValue),
|
|
1676
|
-
className: "".concat(type, "-lunatic"),
|
|
1677
|
-
style: buildStyleObject(style),
|
|
1678
|
-
checked: checked,
|
|
1679
|
-
disabled: disabled,
|
|
1680
|
-
onChange: function onChange(optionLabel) {
|
|
1681
|
-
return _onChange(optionValue);
|
|
1682
|
-
}
|
|
1683
|
-
}), /*#__PURE__*/React__default['default'].createElement("label", {
|
|
1684
|
-
htmlFor: "".concat(type, "-").concat(id, "-").concat(optionValue),
|
|
1685
|
-
id: "input-label-".concat(id, "-").concat(optionValue),
|
|
1686
|
-
style: checked ? buildStyleObject(modalityStyle) : {}
|
|
1687
|
-
}, keyboardSelection && /*#__PURE__*/React__default['default'].createElement("span", {
|
|
1688
|
-
className: "code-modality"
|
|
1689
|
-
}, options.length < 10 ? i + 1 : getAlphabet()[i].toUpperCase()), interpretedLabel));
|
|
1690
|
-
}))), management && /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1691
|
-
className: "tooltip"
|
|
1692
|
-
}, /*#__PURE__*/React__default['default'].createElement(TooltipResponse, {
|
|
1693
|
-
id: id,
|
|
1694
|
-
response: buildMultiTooltipResponse(options)(response)
|
|
1695
|
-
}))), /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
1696
|
-
id: id,
|
|
1697
|
-
type: DETACHABLE,
|
|
1698
|
-
declarations: declarations,
|
|
1699
|
-
features: features,
|
|
1700
|
-
bindings: bindings
|
|
1701
|
-
}));
|
|
1702
|
-
};
|
|
1703
|
-
|
|
1704
|
-
ListDeclarationsWrapper.defaultProps = {
|
|
1705
|
-
label: '',
|
|
1706
|
-
preferences: ['COLLECTED'],
|
|
1707
|
-
response: {},
|
|
1708
|
-
options: [],
|
|
1709
|
-
disabled: false,
|
|
1710
|
-
focused: false,
|
|
1711
|
-
keyboardSelection: false,
|
|
1712
|
-
positioning: 'DEFAULT',
|
|
1713
|
-
declarations: [],
|
|
1714
|
-
features: [],
|
|
1715
|
-
bindings: {},
|
|
1716
|
-
management: false,
|
|
1717
|
-
style: {
|
|
1718
|
-
fieldsetStyle: {},
|
|
1719
|
-
modalityStyle: {}
|
|
1720
|
-
}
|
|
1721
|
-
};
|
|
1722
|
-
ListDeclarationsWrapper.propTypes = {
|
|
1723
|
-
id: PropTypes__default['default'].string.isRequired,
|
|
1724
|
-
label: PropTypes__default['default'].string,
|
|
1725
|
-
preferences: PropTypes__default['default'].arrayOf(valueType),
|
|
1726
|
-
response: response,
|
|
1727
|
-
options: options,
|
|
1728
|
-
handleChange: PropTypes__default['default'].func.isRequired,
|
|
1729
|
-
disabled: PropTypes__default['default'].bool,
|
|
1730
|
-
focused: PropTypes__default['default'].bool,
|
|
1731
|
-
keyboardSelection: PropTypes__default['default'].bool,
|
|
1732
|
-
positioning: PropTypes__default['default'].oneOf(['DEFAULT', 'HORIZONTAL', 'VERTICAL']),
|
|
1733
|
-
declarations: declarations,
|
|
1734
|
-
features: PropTypes__default['default'].arrayOf(PropTypes__default['default'].string),
|
|
1735
|
-
bindings: PropTypes__default['default'].object,
|
|
1736
|
-
management: PropTypes__default['default'].bool,
|
|
1737
|
-
style: PropTypes__default['default'].object,
|
|
1738
|
-
type: PropTypes__default['default'].oneOf(['radio', 'checkbox'])
|
|
1739
|
-
};
|
|
1740
|
-
|
|
1741
|
-
var SimpleDeclarationsWrapper = function SimpleDeclarationsWrapper(_ref) {
|
|
1742
|
-
var id = _ref.id,
|
|
1743
|
-
declarations = _ref.declarations,
|
|
1744
|
-
features = _ref.features,
|
|
1745
|
-
bindings = _ref.bindings,
|
|
1746
|
-
children = _ref.children;
|
|
1747
|
-
return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
1748
|
-
id: id,
|
|
1749
|
-
type: BEFORE_QUESTION_TEXT,
|
|
1750
|
-
declarations: declarations,
|
|
1751
|
-
features: features,
|
|
1752
|
-
bindings: bindings
|
|
1753
|
-
}), children, /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
1754
|
-
id: id,
|
|
1755
|
-
type: AFTER_QUESTION_TEXT,
|
|
1756
|
-
declarations: declarations,
|
|
1757
|
-
features: features,
|
|
1758
|
-
bindings: bindings
|
|
1759
|
-
}), /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
1760
|
-
id: id,
|
|
1761
|
-
type: DETACHABLE,
|
|
1762
|
-
declarations: declarations,
|
|
1763
|
-
features: features,
|
|
1764
|
-
bindings: bindings
|
|
1765
|
-
}));
|
|
1766
|
-
};
|
|
1767
|
-
|
|
1768
|
-
SimpleDeclarationsWrapper.defaultProps = {
|
|
1769
|
-
declarations: [],
|
|
1770
|
-
features: [],
|
|
1771
|
-
bindings: {}
|
|
1772
|
-
};
|
|
1773
|
-
SimpleDeclarationsWrapper.propTypes = {
|
|
1774
|
-
id: PropTypes__default['default'].string.isRequired,
|
|
1775
|
-
declarations: declarations,
|
|
1776
|
-
features: PropTypes__default['default'].arrayOf(PropTypes__default['default'].string),
|
|
1777
|
-
bindings: PropTypes__default['default'].object,
|
|
1778
|
-
children: PropTypes__default['default'].element.isRequired
|
|
1779
|
-
};
|
|
1780
|
-
|
|
1781
|
-
var CheckboxOne = function CheckboxOne(props) {
|
|
1782
|
-
return /*#__PURE__*/React__default['default'].createElement(ListDeclarationsWrapper, _extends({
|
|
1783
|
-
type: "checkbox"
|
|
1784
|
-
}, props, {
|
|
1785
|
-
hasSpecificHandler: true
|
|
1786
|
-
}));
|
|
1787
|
-
};
|
|
1788
|
-
|
|
1789
|
-
var one = /*#__PURE__*/React__default['default'].memo(CheckboxOne, areEqual);
|
|
1790
|
-
|
|
1791
|
-
var css_248z$5 = "* {\n box-sizing: border-box;\n}\n\n.mandatory:after {\n content: \" *\";\n color: red;\n}\n\n.horizontal-options {\n display: inline-block;\n margin-right: 2em;\n}\n\nlabel,\n.lunatic-dropdown-label {\n margin-bottom: 0.5em;\n}\n\n.label-top {\n display: flex;\n flex-direction: column;\n}\n\n.label-bottom {\n display: flex;\n flex-direction: column-reverse;\n}\n\n.label-right {\n justify-content: flex-end;\n display: flex;\n flex-direction: row-reverse;\n align-items: baseline;\n}\n.label-right :first-child {\n margin-right: 1rem;\n}\n\n.label-left {\n display: flex;\n flex-direction: row;\n align-items: baseline;\n}\n.label-left :first-child {\n margin-right: 1rem;\n}\n\n.field-container {\n display: flex;\n}\n\n.tooltip {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n.field-with-tooltip {\n width: calc(100% - 25px);\n position: relative;\n}\n\n.field {\n width: 100%;\n position: relative;\n}\n\n.datepicker-lunatic {\n width: 100%;\n box-sizing: border-box;\n border: solid 2px #e80a4d;\n border-radius: 10px;\n padding: 5px;\n}\n.datepicker-lunatic:focus {\n outline: none;\n box-shadow: 0 0 10px #e80a4d;\n}\n.datepicker-lunatic:read-only {\n background-color: #ebebe4;\n}";
|
|
1792
|
-
styleInject(css_248z$5);
|
|
1793
|
-
|
|
1794
|
-
var Datepicker = function Datepicker(props) {
|
|
1795
|
-
return /*#__PURE__*/React__default['default'].createElement(InputDeclarationsWrapper, _extends({
|
|
1796
|
-
type: "date",
|
|
1797
|
-
roleType: "datepicker"
|
|
1798
|
-
}, props));
|
|
1799
|
-
};
|
|
1800
|
-
|
|
1801
|
-
var component = /*#__PURE__*/React__default['default'].memo(Datepicker, areEqual);
|
|
1802
|
-
|
|
1803
|
-
function createCommonjsModule(fn, module) {
|
|
1804
|
-
return module = { exports: {} }, fn(module, module.exports), module.exports;
|
|
1805
|
-
}
|
|
1806
|
-
|
|
1807
|
-
var classnames = createCommonjsModule(function (module) {
|
|
1808
|
-
/*!
|
|
1809
|
-
Copyright (c) 2017 Jed Watson.
|
|
1810
|
-
Licensed under the MIT License (MIT), see
|
|
1811
|
-
http://jedwatson.github.io/classnames
|
|
1812
|
-
*/
|
|
1813
|
-
/* global define */
|
|
1814
|
-
|
|
1815
|
-
(function () {
|
|
1816
|
-
|
|
1817
|
-
var hasOwn = {}.hasOwnProperty;
|
|
1818
|
-
|
|
1819
|
-
function classNames () {
|
|
1820
|
-
var classes = [];
|
|
1821
|
-
|
|
1822
|
-
for (var i = 0; i < arguments.length; i++) {
|
|
1823
|
-
var arg = arguments[i];
|
|
1824
|
-
if (!arg) continue;
|
|
1825
|
-
|
|
1826
|
-
var argType = typeof arg;
|
|
1827
|
-
|
|
1828
|
-
if (argType === 'string' || argType === 'number') {
|
|
1829
|
-
classes.push(arg);
|
|
1830
|
-
} else if (Array.isArray(arg) && arg.length) {
|
|
1831
|
-
var inner = classNames.apply(null, arg);
|
|
1832
|
-
if (inner) {
|
|
1833
|
-
classes.push(inner);
|
|
1834
|
-
}
|
|
1835
|
-
} else if (argType === 'object') {
|
|
1836
|
-
for (var key in arg) {
|
|
1837
|
-
if (hasOwn.call(arg, key) && arg[key]) {
|
|
1838
|
-
classes.push(key);
|
|
1839
|
-
}
|
|
1840
|
-
}
|
|
1841
|
-
}
|
|
1842
|
-
}
|
|
1843
|
-
|
|
1844
|
-
return classes.join(' ');
|
|
1845
|
-
}
|
|
1846
|
-
|
|
1847
|
-
if ( module.exports) {
|
|
1848
|
-
classNames.default = classNames;
|
|
1849
|
-
module.exports = classNames;
|
|
1850
|
-
} else {
|
|
1851
|
-
window.classNames = classNames;
|
|
1852
|
-
}
|
|
1853
|
-
}());
|
|
1854
|
-
});
|
|
1855
|
-
|
|
1856
|
-
var SHOW_PANEL = "dropdown/show-panel";
|
|
1857
|
-
var showPanel = function showPanel() {
|
|
1858
|
-
return {
|
|
1859
|
-
type: SHOW_PANEL
|
|
1860
|
-
};
|
|
1861
|
-
};
|
|
1862
|
-
var HIDE_PANEL = "dropdown/hide-panel";
|
|
1863
|
-
var hidePanel = function hidePanel() {
|
|
1864
|
-
return {
|
|
1865
|
-
type: HIDE_PANEL
|
|
1866
|
-
};
|
|
1867
|
-
};
|
|
1868
|
-
var SET_ACTIVE_OPTION = "dropdown/set-active-option";
|
|
1869
|
-
var setActiveOption = function setActiveOption(index) {
|
|
1870
|
-
return {
|
|
1871
|
-
type: SET_ACTIVE_OPTION,
|
|
1872
|
-
payload: {
|
|
1873
|
-
index: index
|
|
1874
|
-
}
|
|
1875
|
-
};
|
|
1876
|
-
};
|
|
1877
|
-
var SET_OPTIONS = "dropdown/set-options";
|
|
1878
|
-
var setOptions = function setOptions(options) {
|
|
1879
|
-
return {
|
|
1880
|
-
type: SET_OPTIONS,
|
|
1881
|
-
payload: {
|
|
1882
|
-
options: options
|
|
1883
|
-
}
|
|
1884
|
-
};
|
|
1885
|
-
};
|
|
1886
|
-
var SET_VALUE = "dropdown/set-value";
|
|
1887
|
-
var setValue = function setValue(value) {
|
|
1888
|
-
return {
|
|
1889
|
-
type: SET_VALUE,
|
|
1890
|
-
payload: {
|
|
1891
|
-
value: value
|
|
1892
|
-
}
|
|
1893
|
-
};
|
|
1894
|
-
};
|
|
1895
|
-
var SET_FOCUSED = "dropdown/set-focused";
|
|
1896
|
-
var setFocused = function setFocused(focused) {
|
|
1897
|
-
return {
|
|
1898
|
-
type: SET_FOCUSED,
|
|
1899
|
-
payload: {
|
|
1900
|
-
focused: focused
|
|
1901
|
-
}
|
|
1902
|
-
};
|
|
1903
|
-
};
|
|
1904
|
-
var SET_SELECTED_OPTION = "dropdown/set-selectted-option";
|
|
1905
|
-
var setSelectedOption = function setSelectedOption(option) {
|
|
1906
|
-
return {
|
|
1907
|
-
type: SET_SELECTED_OPTION,
|
|
1908
|
-
payload: {
|
|
1909
|
-
option: option
|
|
1910
|
-
}
|
|
1911
|
-
};
|
|
1912
|
-
};
|
|
1913
|
-
var RESET_SELECTION = "dropdown/reset-selection";
|
|
1914
|
-
var resetSelection = function resetSelection(option) {
|
|
1915
|
-
return {
|
|
1916
|
-
type: RESET_SELECTION
|
|
1917
|
-
};
|
|
1918
|
-
};
|
|
1919
|
-
/* */
|
|
1920
|
-
|
|
1921
|
-
var ARROW_UP_PRESSED = "dropdown/arrow-up-ressed";
|
|
1922
|
-
var arrowUpPressed = function arrowUpPressed() {
|
|
1923
|
-
return {
|
|
1924
|
-
type: ARROW_UP_PRESSED
|
|
1925
|
-
};
|
|
1926
|
-
};
|
|
1927
|
-
/* */
|
|
1928
|
-
|
|
1929
|
-
var ARROW_DOWN_PRESSED = "dropdown/arrow-down-pressed";
|
|
1930
|
-
var arrowDownPressed = function arrowDownPressed() {
|
|
1931
|
-
return {
|
|
1932
|
-
type: ARROW_DOWN_PRESSED
|
|
1933
|
-
};
|
|
1934
|
-
};
|
|
1935
|
-
/* */
|
|
1936
|
-
|
|
1937
|
-
var ENTER_PRESSED = "dropdown/enter-pressed";
|
|
1938
|
-
var enterPressed = function enterPressed(callback) {
|
|
1939
|
-
return {
|
|
1940
|
-
type: ENTER_PRESSED,
|
|
1941
|
-
payload: {
|
|
1942
|
-
callback: callback
|
|
1943
|
-
}
|
|
1944
|
-
};
|
|
1945
|
-
};
|
|
1946
|
-
/* */
|
|
1947
|
-
|
|
1948
|
-
var SET_PREFIX = "dropdown/set-prefix";
|
|
1949
|
-
var setPrefix = function setPrefix(prefix) {
|
|
1950
|
-
return {
|
|
1951
|
-
type: SET_PREFIX,
|
|
1952
|
-
payload: {
|
|
1953
|
-
prefix: prefix
|
|
1954
|
-
}
|
|
1955
|
-
};
|
|
1956
|
-
};
|
|
1957
|
-
|
|
1958
|
-
/**
|
|
1959
|
-
*
|
|
1960
|
-
*/
|
|
1961
|
-
|
|
1962
|
-
function Panel(_ref) {
|
|
1963
|
-
var _ref$options = _ref.options,
|
|
1964
|
-
options = _ref$options === void 0 ? [] : _ref$options,
|
|
1965
|
-
display = _ref.display,
|
|
1966
|
-
handleActive = _ref.handleActive,
|
|
1967
|
-
prefix = _ref.prefix,
|
|
1968
|
-
activeIndex = _ref.activeIndex,
|
|
1969
|
-
selectedOption = _ref.selectedOption,
|
|
1970
|
-
onSelect = _ref.onSelect,
|
|
1971
|
-
idDropdown = _ref.idDropdown,
|
|
1972
|
-
Option = _ref.optionComponent;
|
|
1973
|
-
var ulRef = React.useRef();
|
|
1974
|
-
return display ? /*#__PURE__*/React__default['default'].createElement("div", {
|
|
1975
|
-
className: "lunatic-dropdown-panel-container"
|
|
1976
|
-
}, /*#__PURE__*/React__default['default'].createElement("ul", {
|
|
1977
|
-
className: "lunatic-dropdown-panel",
|
|
1978
|
-
ref: ulRef,
|
|
1979
|
-
tabIndex: "-1"
|
|
1980
|
-
}, options.map(function (_ref2, index) {
|
|
1981
|
-
var label = _ref2.label,
|
|
1982
|
-
value = _ref2.value;
|
|
1983
|
-
return /*#__PURE__*/React__default['default'].createElement("li", {
|
|
1984
|
-
key: value,
|
|
1985
|
-
id: "".concat(idDropdown, "-option-").concat(value),
|
|
1986
|
-
onMouseEnter: function onMouseEnter() {
|
|
1987
|
-
return handleActive(index);
|
|
1988
|
-
},
|
|
1989
|
-
onMouseDown: function onMouseDown(e) {
|
|
1990
|
-
e.stopPropagation();
|
|
1991
|
-
e.preventDefault();
|
|
1992
|
-
|
|
1993
|
-
if (e.button === 0) {
|
|
1994
|
-
onSelect({
|
|
1995
|
-
label: label,
|
|
1996
|
-
value: value
|
|
1997
|
-
});
|
|
1998
|
-
}
|
|
1999
|
-
}
|
|
2000
|
-
}, /*#__PURE__*/React__default['default'].createElement(Option, {
|
|
2001
|
-
label: label,
|
|
2002
|
-
value: value,
|
|
2003
|
-
prefix: prefix,
|
|
2004
|
-
active: activeIndex === index,
|
|
2005
|
-
selected: selectedOption && selectedOption.value === value
|
|
2006
|
-
}));
|
|
2007
|
-
}))) : null;
|
|
2008
|
-
}
|
|
2009
|
-
|
|
2010
|
-
var propTypesOption = PropTypes__default['default'].shape({
|
|
2011
|
-
label: PropTypes__default['default'].string,
|
|
2012
|
-
value: PropTypes__default['default'].oneOfType([PropTypes__default['default'].string, PropTypes__default['default'].object, PropTypes__default['default'].number, PropTypes__default['default'].symbol, PropTypes__default['default'].bool])
|
|
2013
|
-
});
|
|
2014
|
-
Panel.propTypes = {
|
|
2015
|
-
idDropdown: PropTypes__default['default'].string.isRequired,
|
|
2016
|
-
prefix: PropTypes__default['default'].string,
|
|
2017
|
-
onSelect: PropTypes__default['default'].func,
|
|
2018
|
-
handleActive: PropTypes__default['default'].func.isRequired,
|
|
2019
|
-
activeIndex: PropTypes__default['default'].number,
|
|
2020
|
-
selectedOption: propTypesOption,
|
|
2021
|
-
display: PropTypes__default['default'].bool.isRequired,
|
|
2022
|
-
options: PropTypes__default['default'].arrayOf(propTypesOption)
|
|
2023
|
-
};
|
|
2024
|
-
Panel.defaultProps = {
|
|
2025
|
-
options: [],
|
|
2026
|
-
onSelect: function onSelect() {
|
|
2027
|
-
return null;
|
|
2028
|
-
},
|
|
2029
|
-
selectedOption: undefined
|
|
2030
|
-
};
|
|
2031
|
-
|
|
2032
|
-
function Icon(_ref) {
|
|
2033
|
-
var _ref$height = _ref.height,
|
|
2034
|
-
height = _ref$height === void 0 ? 20 : _ref$height,
|
|
2035
|
-
_ref$width = _ref.width,
|
|
2036
|
-
width = _ref$width === void 0 ? 20 : _ref$width,
|
|
2037
|
-
_ref$color = _ref.color,
|
|
2038
|
-
color = _ref$color === void 0 ? "#aaa" : _ref$color;
|
|
2039
|
-
return /*#__PURE__*/React__default['default'].createElement("svg", {
|
|
2040
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
2041
|
-
width: width,
|
|
2042
|
-
height: height,
|
|
2043
|
-
x: "0",
|
|
2044
|
-
y: "0",
|
|
2045
|
-
enableBackground: "new 0 0 292.362 292.362",
|
|
2046
|
-
version: "1.1",
|
|
2047
|
-
viewBox: "0 0 292.362 292.362",
|
|
2048
|
-
xmlSpace: "preserve"
|
|
2049
|
-
}, /*#__PURE__*/React__default['default'].createElement("path", {
|
|
2050
|
-
fill: color,
|
|
2051
|
-
d: "M286.935 69.377c-3.614-3.617-7.898-5.424-12.848-5.424H18.274c-4.952 0-9.233 1.807-12.85 5.424C1.807 72.998 0 77.279 0 82.228c0 4.948 1.807 9.229 5.424 12.847l127.907 127.907c3.621 3.617 7.902 5.428 12.85 5.428s9.233-1.811 12.847-5.428L286.935 95.074c3.613-3.617 5.427-7.898 5.427-12.847 0-4.948-1.814-9.229-5.427-12.85z"
|
|
2052
|
-
}));
|
|
2053
|
-
}
|
|
2054
|
-
|
|
2055
|
-
function Icon$1(_ref) {
|
|
2056
|
-
var _ref$height = _ref.height,
|
|
2057
|
-
height = _ref$height === void 0 ? 20 : _ref$height,
|
|
2058
|
-
_ref$width = _ref.width,
|
|
2059
|
-
width = _ref$width === void 0 ? 20 : _ref$width,
|
|
2060
|
-
_ref$color = _ref.color,
|
|
2061
|
-
color = _ref$color === void 0 ? "#aaa" : _ref$color;
|
|
2062
|
-
return /*#__PURE__*/React__default['default'].createElement("svg", {
|
|
2063
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
2064
|
-
width: width,
|
|
2065
|
-
height: height,
|
|
2066
|
-
x: "0",
|
|
2067
|
-
y: "0",
|
|
2068
|
-
enableBackground: "new 0 0 292.362 292.362",
|
|
2069
|
-
version: "1.1",
|
|
2070
|
-
viewBox: "0 0 292.362 292.362",
|
|
2071
|
-
xmlSpace: "preserve"
|
|
2072
|
-
}, /*#__PURE__*/React__default['default'].createElement("path", {
|
|
2073
|
-
fill: color,
|
|
2074
|
-
d: "M286.935 197.286L159.028 69.379c-3.613-3.617-7.895-5.424-12.847-5.424s-9.233 1.807-12.85 5.424L5.424 197.286C1.807 200.9 0 205.184 0 210.132s1.807 9.233 5.424 12.847c3.621 3.617 7.902 5.428 12.85 5.428h255.813c4.949 0 9.233-1.811 12.848-5.428 3.613-3.613 5.427-7.898 5.427-12.847s-1.814-9.232-5.427-12.846z"
|
|
2075
|
-
}));
|
|
2076
|
-
}
|
|
2077
|
-
|
|
2078
|
-
function Label(_ref) {
|
|
2079
|
-
var content = _ref.content,
|
|
2080
|
-
focused = _ref.focused,
|
|
2081
|
-
mandatory = _ref.mandatory;
|
|
2082
|
-
|
|
2083
|
-
if (!content) {
|
|
2084
|
-
return null;
|
|
2085
|
-
}
|
|
2086
|
-
|
|
2087
|
-
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
2088
|
-
className: classnames('lunatic-dropdown-label', {
|
|
2089
|
-
focused: focused,
|
|
2090
|
-
mandatory: mandatory
|
|
2091
|
-
})
|
|
2092
|
-
}, content);
|
|
2093
|
-
}
|
|
2094
|
-
|
|
2095
|
-
Label.defaultProps = {
|
|
2096
|
-
mandatory: false
|
|
2097
|
-
};
|
|
2098
|
-
Label.propTypes = {
|
|
2099
|
-
content: PropTypes__default['default'].string,
|
|
2100
|
-
focused: PropTypes__default['default'].bool.isRequired,
|
|
2101
|
-
mandatory: PropTypes__default['default'].bool
|
|
2102
|
-
};
|
|
2103
|
-
|
|
2104
|
-
var CLEANER_CALLBACKS = {};
|
|
2105
|
-
/**
|
|
2106
|
-
*
|
|
2107
|
-
* @param {...any} execpt identifiants de dropdownn a ne pas appliquer
|
|
2108
|
-
*/
|
|
2109
|
-
|
|
2110
|
-
var applyAll = function applyAll() {
|
|
2111
|
-
for (var _len = arguments.length, execpt = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
2112
|
-
execpt[_key] = arguments[_key];
|
|
2113
|
-
}
|
|
2114
|
-
|
|
2115
|
-
Object.entries(CLEANER_CALLBACKS).forEach(function (_ref) {
|
|
2116
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
2117
|
-
k = _ref2[0];
|
|
2118
|
-
_ref2[1];
|
|
2119
|
-
|
|
2120
|
-
if (execpt.indexOf(k) === -1) {
|
|
2121
|
-
apply(k);
|
|
2122
|
-
}
|
|
2123
|
-
});
|
|
2124
|
-
};
|
|
2125
|
-
/**
|
|
2126
|
-
* Applique une fonction pour l'identifiant transmis
|
|
2127
|
-
* @param {string} id
|
|
2128
|
-
*/
|
|
2129
|
-
|
|
2130
|
-
var apply = function apply(id) {
|
|
2131
|
-
if (id in CLEANER_CALLBACKS && typeof CLEANER_CALLBACKS[id] === "function") {
|
|
2132
|
-
CLEANER_CALLBACKS[id]();
|
|
2133
|
-
}
|
|
2134
|
-
};
|
|
2135
|
-
/**
|
|
2136
|
-
*
|
|
2137
|
-
* @param {string} id
|
|
2138
|
-
* @param {function} callback
|
|
2139
|
-
*/
|
|
2140
|
-
|
|
2141
|
-
var add = function add(id, callback) {
|
|
2142
|
-
if (typeof callback === "function") {
|
|
2143
|
-
CLEANER_CALLBACKS[id] = callback;
|
|
2144
|
-
}
|
|
2145
|
-
};
|
|
2146
|
-
/**
|
|
2147
|
-
*
|
|
2148
|
-
* @param {string} id
|
|
2149
|
-
*/
|
|
2150
|
-
|
|
2151
|
-
var clear = function clear(id) {
|
|
2152
|
-
delete CLEANER_CALLBACKS[id];
|
|
2153
|
-
};
|
|
2154
|
-
|
|
2155
|
-
function DropdownFieldContainer(_ref) {
|
|
2156
|
-
var children = _ref.children,
|
|
2157
|
-
id = _ref.id,
|
|
2158
|
-
response = _ref.response,
|
|
2159
|
-
options = _ref.options,
|
|
2160
|
-
management = _ref.management,
|
|
2161
|
-
focused = _ref.focused,
|
|
2162
|
-
visible = _ref.visible,
|
|
2163
|
-
disabled = _ref.disabled;
|
|
2164
|
-
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
2165
|
-
className: "field-container"
|
|
2166
|
-
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
2167
|
-
className: "".concat(management ? 'field-with-tooltip' : 'field')
|
|
2168
|
-
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
2169
|
-
tabIndex: "-1",
|
|
2170
|
-
className: classnames('lunatic-dropdown-container', {
|
|
2171
|
-
focused: focused
|
|
2172
|
-
})
|
|
2173
|
-
}, /*#__PURE__*/React__default['default'].createElement("span", {
|
|
2174
|
-
className: classnames("lunatic-dropdown-content", {
|
|
2175
|
-
focused: focused,
|
|
2176
|
-
visible: visible,
|
|
2177
|
-
disabled: disabled
|
|
2178
|
-
})
|
|
2179
|
-
}, children))), management && /*#__PURE__*/React__default['default'].createElement("div", {
|
|
2180
|
-
className: "tooltip"
|
|
2181
|
-
}, /*#__PURE__*/React__default['default'].createElement(TooltipResponse, {
|
|
2182
|
-
id: id,
|
|
2183
|
-
response: buildMultiTooltipResponse(options)(response)
|
|
2184
|
-
})));
|
|
2185
|
-
}
|
|
2186
|
-
|
|
2187
|
-
var DropdownContainer = /*#__PURE__*/React__default['default'].forwardRef(function (props, ref) {
|
|
2188
|
-
var children = props.children,
|
|
2189
|
-
className = props.className,
|
|
2190
|
-
id = props.id,
|
|
2191
|
-
onMouseDown = props.onMouseDown,
|
|
2192
|
-
onKeyDown = props.onKeyDown,
|
|
2193
|
-
onFocus = props.onFocus,
|
|
2194
|
-
onBlur = props.onBlur;
|
|
2195
|
-
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
2196
|
-
className: className,
|
|
2197
|
-
tabIndex: "0",
|
|
2198
|
-
id: id,
|
|
2199
|
-
onMouseDown: onMouseDown,
|
|
2200
|
-
onKeyDown: onKeyDown,
|
|
2201
|
-
onFocus: onFocus,
|
|
2202
|
-
onBlur: onBlur,
|
|
2203
|
-
ref: ref
|
|
2204
|
-
}, children);
|
|
2205
|
-
});
|
|
2206
|
-
|
|
2207
|
-
var BINDED_KEYS = {
|
|
2208
|
-
arrowUp: 'ArrowUp',
|
|
2209
|
-
arrowDown: 'ArrowDown',
|
|
2210
|
-
enter: 'Enter',
|
|
2211
|
-
tab: 'Tab'
|
|
2212
|
-
};
|
|
2213
|
-
/** */
|
|
2214
|
-
|
|
2215
|
-
var createOnKeyDownCallback = (function (_, dispatch, onSelect) {
|
|
2216
|
-
return function (key) {
|
|
2217
|
-
switch (key) {
|
|
2218
|
-
case BINDED_KEYS.arrowUp:
|
|
2219
|
-
dispatch(arrowUpPressed());
|
|
2220
|
-
break;
|
|
2221
|
-
|
|
2222
|
-
case BINDED_KEYS.arrowDown:
|
|
2223
|
-
dispatch(arrowDownPressed());
|
|
2224
|
-
dispatch(showPanel());
|
|
2225
|
-
break;
|
|
2226
|
-
|
|
2227
|
-
case BINDED_KEYS.enter:
|
|
2228
|
-
dispatch(enterPressed(onSelect));
|
|
2229
|
-
break;
|
|
2230
|
-
|
|
2231
|
-
case BINDED_KEYS.tab:
|
|
2232
|
-
dispatch(setFocused(false));
|
|
2233
|
-
dispatch(hidePanel());
|
|
2234
|
-
break;
|
|
2235
|
-
}
|
|
2236
|
-
};
|
|
2237
|
-
});
|
|
2238
|
-
|
|
2239
|
-
/** */
|
|
2240
|
-
|
|
2241
|
-
var createOnMouseDownCallback = (function (_ref, dispatch) {
|
|
2242
|
-
var visible = _ref.visible,
|
|
2243
|
-
id = _ref.id,
|
|
2244
|
-
disabled = _ref.disabled;
|
|
2245
|
-
return function (e) {
|
|
2246
|
-
e.stopPropagation();
|
|
2247
|
-
|
|
2248
|
-
if (!visible && !disabled) {
|
|
2249
|
-
applyAll(id);
|
|
2250
|
-
dispatch(showPanel());
|
|
2251
|
-
}
|
|
2252
|
-
};
|
|
2253
|
-
});
|
|
2254
|
-
|
|
2255
|
-
/** */
|
|
2256
|
-
|
|
2257
|
-
function stopAndPrevent(e) {
|
|
2258
|
-
e.preventDefault();
|
|
2259
|
-
e.stopPropagation();
|
|
2260
|
-
}
|
|
2261
|
-
/** */
|
|
2262
|
-
|
|
2263
|
-
|
|
2264
|
-
function prepareOptions(options, valueFromProps) {
|
|
2265
|
-
return options.reduce(function (a, o, i) {
|
|
2266
|
-
return o.value === valueFromProps && a.index === -1 ? {
|
|
2267
|
-
index: i,
|
|
2268
|
-
option: o
|
|
2269
|
-
} : a;
|
|
2270
|
-
}, {
|
|
2271
|
-
index: -1,
|
|
2272
|
-
option: {}
|
|
2273
|
-
});
|
|
2274
|
-
}
|
|
2275
|
-
/** */
|
|
2276
|
-
|
|
2277
|
-
|
|
2278
|
-
function onKeyDownCallbackProxy(state, dispatch, onSelect) {
|
|
2279
|
-
var callback = createOnKeyDownCallback(state, dispatch, onSelect);
|
|
2280
|
-
return function (e) {
|
|
2281
|
-
switch (e.key) {
|
|
2282
|
-
case BINDED_KEYS.enter:
|
|
2283
|
-
case BINDED_KEYS.arrowUp:
|
|
2284
|
-
case BINDED_KEYS.arrowDown:
|
|
2285
|
-
stopAndPrevent(e);
|
|
2286
|
-
callback(e.key);
|
|
2287
|
-
break;
|
|
2288
|
-
|
|
2289
|
-
case BINDED_KEYS.tab:
|
|
2290
|
-
callback(e.key);
|
|
2291
|
-
break;
|
|
2292
|
-
}
|
|
2293
|
-
};
|
|
2294
|
-
}
|
|
2295
|
-
|
|
2296
|
-
function Dropdown(_ref) {
|
|
2297
|
-
var options = _ref.options,
|
|
2298
|
-
children = _ref.children,
|
|
2299
|
-
onSelect = _ref.onSelect,
|
|
2300
|
-
response = _ref.response,
|
|
2301
|
-
className = _ref.className,
|
|
2302
|
-
label = _ref.label,
|
|
2303
|
-
labelPosition = _ref.labelPosition,
|
|
2304
|
-
mandatory = _ref.mandatory,
|
|
2305
|
-
valueFromProps = _ref.value,
|
|
2306
|
-
management = _ref.management,
|
|
2307
|
-
state = _ref.state,
|
|
2308
|
-
dispatch = _ref.dispatch,
|
|
2309
|
-
refs = _ref.refs;
|
|
2310
|
-
var visible = state.visible,
|
|
2311
|
-
focused = state.focused,
|
|
2312
|
-
id = state.id,
|
|
2313
|
-
disabled = state.disabled;
|
|
2314
|
-
add(id, function () {
|
|
2315
|
-
dispatch(hidePanel());
|
|
2316
|
-
dispatch(setFocused(false));
|
|
2317
|
-
});
|
|
2318
|
-
React.useEffect(function () {
|
|
2319
|
-
var hook = function hook() {
|
|
2320
|
-
dispatch(hidePanel());
|
|
2321
|
-
dispatch(setFocused(false));
|
|
2322
|
-
};
|
|
2323
|
-
|
|
2324
|
-
window.addEventListener('mousedown', hook);
|
|
2325
|
-
return function () {
|
|
2326
|
-
window.removeEventListener('mousedown', hook);
|
|
2327
|
-
clear(id);
|
|
2328
|
-
};
|
|
2329
|
-
}, [id, dispatch]);
|
|
2330
|
-
React.useEffect(function () {
|
|
2331
|
-
dispatch(setOptions(options));
|
|
2332
|
-
}, [options, dispatch]);
|
|
2333
|
-
React.useEffect(function () {
|
|
2334
|
-
if (valueFromProps) {
|
|
2335
|
-
var _prepareOptions = prepareOptions(options, valueFromProps),
|
|
2336
|
-
option = _prepareOptions.option,
|
|
2337
|
-
index = _prepareOptions.index;
|
|
2338
|
-
|
|
2339
|
-
dispatch(setSelectedOption(option));
|
|
2340
|
-
dispatch(setActiveOption(index));
|
|
2341
|
-
}
|
|
2342
|
-
}, [valueFromProps, options, dispatch]);
|
|
2343
|
-
var onFocus = React.useCallback(function () {
|
|
2344
|
-
dispatch(setFocused( !disabled));
|
|
2345
|
-
}, [dispatch, disabled]);
|
|
2346
|
-
var onBlur = React.useCallback(function () {
|
|
2347
|
-
dispatch(setFocused(false));
|
|
2348
|
-
}, [dispatch]);
|
|
2349
|
-
var onMouseDownCallback = React.useCallback(createOnMouseDownCallback(state, dispatch), [state, dispatch]);
|
|
2350
|
-
var onKeyDownCallback = React.useCallback(onKeyDownCallbackProxy(state, dispatch, onSelect), [state, dispatch, onSelect]);
|
|
2351
|
-
return /*#__PURE__*/React__default['default'].createElement(DropdownContainer, {
|
|
2352
|
-
className: classnames(className, getLabelPositionClass(labelPosition), {
|
|
2353
|
-
focused: focused,
|
|
2354
|
-
disabled: disabled
|
|
2355
|
-
}),
|
|
2356
|
-
id: id,
|
|
2357
|
-
onMouseDown: onMouseDownCallback,
|
|
2358
|
-
onKeyDown: onKeyDownCallback,
|
|
2359
|
-
onFocus: onFocus,
|
|
2360
|
-
onBlur: onBlur,
|
|
2361
|
-
ref: refs
|
|
2362
|
-
}, /*#__PURE__*/React__default['default'].createElement(Label, {
|
|
2363
|
-
content: label,
|
|
2364
|
-
focused: focused,
|
|
2365
|
-
mandatory: mandatory
|
|
2366
|
-
}), /*#__PURE__*/React__default['default'].createElement(DropdownFieldContainer, {
|
|
2367
|
-
id: id,
|
|
2368
|
-
response: response,
|
|
2369
|
-
options: options,
|
|
2370
|
-
management: management,
|
|
2371
|
-
focused: focused,
|
|
2372
|
-
visible: visible,
|
|
2373
|
-
disabled: disabled
|
|
2374
|
-
}, children));
|
|
2375
|
-
}
|
|
2376
|
-
|
|
2377
|
-
Dropdown.propTypes = {
|
|
2378
|
-
zIndex: PropTypes__default['default'].number,
|
|
2379
|
-
className: PropTypes__default['default'].string,
|
|
2380
|
-
id: PropTypes__default['default'].string,
|
|
2381
|
-
options: PropTypes__default['default'].array.isRequired,
|
|
2382
|
-
onSelect: PropTypes__default['default'].func,
|
|
2383
|
-
value: PropTypes__default['default'].oneOfType([PropTypes__default['default'].string, PropTypes__default['default'].number, PropTypes__default['default'].object, PropTypes__default['default'].bool])
|
|
2384
|
-
};
|
|
2385
|
-
Dropdown.defaultProps = {
|
|
2386
|
-
options: [],
|
|
2387
|
-
zIndex: 0,
|
|
2388
|
-
onSelect: function onSelect() {
|
|
2389
|
-
return null;
|
|
2390
|
-
}
|
|
2391
|
-
};
|
|
2392
|
-
var DropdownContainer$1 = /*#__PURE__*/React__default['default'].forwardRef(function (props, ref) {
|
|
2393
|
-
return /*#__PURE__*/React__default['default'].createElement(Dropdown, _extends({}, props, {
|
|
2394
|
-
refs: ref
|
|
2395
|
-
}));
|
|
2396
|
-
});
|
|
2397
|
-
|
|
2398
|
-
/** */
|
|
2399
|
-
var scrollTo = function scrollTo(id) {
|
|
2400
|
-
var li = document.getElementById(id);
|
|
2401
|
-
|
|
2402
|
-
if (li) {
|
|
2403
|
-
var parent = li.parentNode;
|
|
2404
|
-
var pr = parent.getBoundingClientRect();
|
|
2405
|
-
var lr = li.getBoundingClientRect();
|
|
2406
|
-
var top = lr.top - pr.top + parent.scrollTop;
|
|
2407
|
-
var bottom = lr.bottom - pr.top + parent.scrollTop;
|
|
2408
|
-
|
|
2409
|
-
if (bottom > parent.scrollTop + pr.height) {
|
|
2410
|
-
parent.scrollTo(0, bottom - pr.height);
|
|
2411
|
-
} else if (top < parent.scrollTop) {
|
|
2412
|
-
parent.scrollTo(0, top);
|
|
2413
|
-
}
|
|
2414
|
-
}
|
|
2415
|
-
};
|
|
2416
|
-
|
|
2417
|
-
var preparePrefix = function preparePrefix(prefix) {
|
|
2418
|
-
return typeof prefix === 'string' ? removeAccents__default['default'](prefix.toLowerCase()).replace(/[- ']/g, '') : prefix;
|
|
2419
|
-
};
|
|
2420
|
-
var lettersMatching = function lettersMatching(label) {
|
|
2421
|
-
var prefix = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
2422
|
-
var pref = prefix.split('');
|
|
2423
|
-
var pos = -1;
|
|
2424
|
-
var clean = preparePrefix(label);
|
|
2425
|
-
return clean.split('').reduce(function (a, c, idx) {
|
|
2426
|
-
if (pos < pref.length && pref[pos + 1] === c) {
|
|
2427
|
-
pos++;
|
|
2428
|
-
return [].concat(_toConsumableArray(a), [c]);
|
|
2429
|
-
}
|
|
2430
|
-
|
|
2431
|
-
return a;
|
|
2432
|
-
}, []);
|
|
2433
|
-
};
|
|
2434
|
-
var match = function match(label, prefix) {
|
|
2435
|
-
var pref = prefix.split('');
|
|
2436
|
-
var pos = -1;
|
|
2437
|
-
var clean = preparePrefix(label);
|
|
2438
|
-
return clean.split('').reduce(function (a, c, idx) {
|
|
2439
|
-
if (pos < pref.length && pref[pos + 1] === c) {
|
|
2440
|
-
pos++;
|
|
2441
|
-
return a + 1;
|
|
2442
|
-
}
|
|
2443
|
-
|
|
2444
|
-
return a / (idx * 0.0001 + 1);
|
|
2445
|
-
}, 0) / prefix.length;
|
|
2446
|
-
};
|
|
2447
|
-
/** */
|
|
2448
|
-
|
|
2449
|
-
var filterOption = function filterOption(options, prefix) {
|
|
2450
|
-
if (!prefix || prefix.length === 0) {
|
|
2451
|
-
return options;
|
|
2452
|
-
}
|
|
2453
|
-
|
|
2454
|
-
return options.reduce(function (acc, o) {
|
|
2455
|
-
var label = o.label,
|
|
2456
|
-
search = o.search;
|
|
2457
|
-
var how = match(search || label, prefix);
|
|
2458
|
-
return how >= 0.6 ? [{
|
|
2459
|
-
o: o,
|
|
2460
|
-
how: how
|
|
2461
|
-
}].concat(_toConsumableArray(acc)).sort(function (a, b) {
|
|
2462
|
-
return a.how <= b.how;
|
|
2463
|
-
}) : acc;
|
|
2464
|
-
}, []).map(function (_ref) {
|
|
2465
|
-
var o = _ref.o;
|
|
2466
|
-
return o;
|
|
2467
|
-
});
|
|
2468
|
-
};
|
|
2469
|
-
|
|
2470
|
-
var initial = {
|
|
2471
|
-
prefix: undefined,
|
|
2472
|
-
options: [],
|
|
2473
|
-
visibleOptions: [],
|
|
2474
|
-
visible: false,
|
|
2475
|
-
activeIndex: undefined,
|
|
2476
|
-
selectedOption: undefined,
|
|
2477
|
-
focused: false,
|
|
2478
|
-
value: ''
|
|
2479
|
-
};
|
|
2480
|
-
/** */
|
|
2481
|
-
|
|
2482
|
-
var isPrefix = function isPrefix(prefix) {
|
|
2483
|
-
return prefix !== undefined && prefix.length > 0;
|
|
2484
|
-
};
|
|
2485
|
-
/** */
|
|
2486
|
-
|
|
2487
|
-
|
|
2488
|
-
var reduceArrowDownPressed = function reduceArrowDownPressed(state) {
|
|
2489
|
-
var visibleOptions = state.visibleOptions,
|
|
2490
|
-
activeIndex = state.activeIndex;
|
|
2491
|
-
var next = visibleOptions.length ? Math.min(visibleOptions.length - 1, activeIndex === undefined ? 0 : activeIndex + 1) : undefined;
|
|
2492
|
-
|
|
2493
|
-
if (next !== undefined) {
|
|
2494
|
-
scrollTo("".concat(state.id, "-option-").concat(visibleOptions[next].value));
|
|
2495
|
-
}
|
|
2496
|
-
|
|
2497
|
-
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
2498
|
-
activeIndex: next
|
|
2499
|
-
});
|
|
2500
|
-
};
|
|
2501
|
-
/** */
|
|
2502
|
-
|
|
2503
|
-
|
|
2504
|
-
var reduceArrowUpPressed = function reduceArrowUpPressed(state) {
|
|
2505
|
-
var visibleOptions = state.visibleOptions,
|
|
2506
|
-
activeIndex = state.activeIndex;
|
|
2507
|
-
var next = visibleOptions.length ? Math.max(0, activeIndex === undefined ? 0 : activeIndex - 1) : undefined;
|
|
2508
|
-
|
|
2509
|
-
if (next !== undefined) {
|
|
2510
|
-
scrollTo("".concat(state.id, "-option-").concat(visibleOptions[next].value));
|
|
2511
|
-
}
|
|
2512
|
-
|
|
2513
|
-
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
2514
|
-
activeIndex: next
|
|
2515
|
-
});
|
|
2516
|
-
};
|
|
2517
|
-
/** */
|
|
2518
|
-
|
|
2519
|
-
|
|
2520
|
-
var reduceEnterPressed = function reduceEnterPressed(state, callback) {
|
|
2521
|
-
var activeIndex = state.activeIndex,
|
|
2522
|
-
visibleOptions = state.visibleOptions,
|
|
2523
|
-
visible = state.visible;
|
|
2524
|
-
|
|
2525
|
-
if (!visible) {
|
|
2526
|
-
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
2527
|
-
visible: true
|
|
2528
|
-
});
|
|
2529
|
-
}
|
|
2530
|
-
|
|
2531
|
-
if (activeIndex !== undefined) {
|
|
2532
|
-
var option = visibleOptions[activeIndex];
|
|
2533
|
-
callback(option);
|
|
2534
|
-
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
2535
|
-
selectedOption: option,
|
|
2536
|
-
value: option.label,
|
|
2537
|
-
prefix: preparePrefix(option.label),
|
|
2538
|
-
visible: false
|
|
2539
|
-
});
|
|
2540
|
-
}
|
|
2541
|
-
|
|
2542
|
-
return state;
|
|
2543
|
-
};
|
|
2544
|
-
/** */
|
|
2545
|
-
|
|
2546
|
-
|
|
2547
|
-
var reducer = function reducer(state, action) {
|
|
2548
|
-
var type = action.type,
|
|
2549
|
-
payload = action.payload;
|
|
2550
|
-
|
|
2551
|
-
switch (type) {
|
|
2552
|
-
case SHOW_PANEL:
|
|
2553
|
-
{
|
|
2554
|
-
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
2555
|
-
visible: true
|
|
2556
|
-
});
|
|
2557
|
-
}
|
|
2558
|
-
|
|
2559
|
-
case HIDE_PANEL:
|
|
2560
|
-
{
|
|
2561
|
-
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
2562
|
-
visible: false
|
|
2563
|
-
});
|
|
2564
|
-
}
|
|
2565
|
-
|
|
2566
|
-
case SET_ACTIVE_OPTION:
|
|
2567
|
-
{
|
|
2568
|
-
var index = payload.index;
|
|
2569
|
-
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
2570
|
-
activeIndex: index
|
|
2571
|
-
});
|
|
2572
|
-
}
|
|
2573
|
-
|
|
2574
|
-
case SET_OPTIONS:
|
|
2575
|
-
{
|
|
2576
|
-
var options = payload.options;
|
|
2577
|
-
var prefix = state.prefix;
|
|
2578
|
-
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
2579
|
-
options: options,
|
|
2580
|
-
visibleOptions: isPrefix(prefix) ? filterOption(options) : options
|
|
2581
|
-
});
|
|
2582
|
-
}
|
|
2583
|
-
|
|
2584
|
-
case SET_PREFIX:
|
|
2585
|
-
{
|
|
2586
|
-
var _prefix = payload.prefix;
|
|
2587
|
-
var _options = state.options;
|
|
2588
|
-
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
2589
|
-
prefix: _prefix,
|
|
2590
|
-
activeIndex: undefined,
|
|
2591
|
-
visibleOptions: isPrefix(_prefix) ? filterOption(_options, _prefix) : _options
|
|
2592
|
-
});
|
|
2593
|
-
}
|
|
2594
|
-
|
|
2595
|
-
case SET_VALUE:
|
|
2596
|
-
{
|
|
2597
|
-
var value = payload.value;
|
|
2598
|
-
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
2599
|
-
value: value
|
|
2600
|
-
});
|
|
2601
|
-
}
|
|
2602
|
-
|
|
2603
|
-
case SET_SELECTED_OPTION:
|
|
2604
|
-
{
|
|
2605
|
-
var option = payload.option;
|
|
2606
|
-
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
2607
|
-
value: option.label,
|
|
2608
|
-
selectedOption: option,
|
|
2609
|
-
prefix: preparePrefix(option.label)
|
|
2610
|
-
});
|
|
2611
|
-
}
|
|
2612
|
-
|
|
2613
|
-
case SET_FOCUSED:
|
|
2614
|
-
{
|
|
2615
|
-
var focused = payload.focused;
|
|
2616
|
-
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
2617
|
-
focused: focused
|
|
2618
|
-
});
|
|
2619
|
-
}
|
|
2620
|
-
|
|
2621
|
-
case RESET_SELECTION:
|
|
2622
|
-
{
|
|
2623
|
-
return _objectSpread2(_objectSpread2({}, state), {}, {
|
|
2624
|
-
prefix: undefined,
|
|
2625
|
-
value: '',
|
|
2626
|
-
selectedOption: undefined,
|
|
2627
|
-
activeIndex: undefined,
|
|
2628
|
-
activeOption: undefined,
|
|
2629
|
-
visibleOptions: state.options
|
|
2630
|
-
});
|
|
2631
|
-
}
|
|
2632
|
-
|
|
2633
|
-
case ARROW_UP_PRESSED:
|
|
2634
|
-
{
|
|
2635
|
-
return reduceArrowUpPressed(state);
|
|
2636
|
-
}
|
|
2637
|
-
|
|
2638
|
-
case ARROW_DOWN_PRESSED:
|
|
2639
|
-
{
|
|
2640
|
-
return reduceArrowDownPressed(state);
|
|
2641
|
-
}
|
|
2642
|
-
|
|
2643
|
-
case ENTER_PRESSED:
|
|
2644
|
-
{
|
|
2645
|
-
var callback = payload.callback;
|
|
2646
|
-
return reduceEnterPressed(state, callback);
|
|
2647
|
-
}
|
|
2648
|
-
|
|
2649
|
-
default:
|
|
2650
|
-
return state;
|
|
2651
|
-
}
|
|
2652
|
-
};
|
|
2653
|
-
|
|
2654
|
-
var Option = (function (_ref) {
|
|
2655
|
-
var label = _ref.label,
|
|
2656
|
-
active = _ref.active,
|
|
2657
|
-
selected = _ref.selected;
|
|
2658
|
-
return /*#__PURE__*/React__default['default'].createElement("span", {
|
|
2659
|
-
className: classnames('lunatic-dropdown-option', {
|
|
2660
|
-
'lunatic-dropdown-option-active': active,
|
|
2661
|
-
'lunatic-dropdown-option-selected': selected
|
|
2662
|
-
})
|
|
2663
|
-
}, label);
|
|
2664
|
-
});
|
|
2665
|
-
|
|
2666
|
-
var Dropdown$1 = function Dropdown(_ref) {
|
|
2667
|
-
var widthAuto = _ref.widthAuto,
|
|
2668
|
-
initId = _ref.id,
|
|
2669
|
-
label = _ref.label,
|
|
2670
|
-
value = _ref.value,
|
|
2671
|
-
options = _ref.options,
|
|
2672
|
-
response = _ref.response,
|
|
2673
|
-
onSelect = _ref.onSelect,
|
|
2674
|
-
placeholder = _ref.placeholder,
|
|
2675
|
-
disabled = _ref.disabled,
|
|
2676
|
-
initFocused = _ref.focused,
|
|
2677
|
-
mandatory = _ref.mandatory,
|
|
2678
|
-
labelPosition = _ref.labelPosition,
|
|
2679
|
-
management = _ref.management,
|
|
2680
|
-
className = _ref.className,
|
|
2681
|
-
zIndex = _ref.zIndex;
|
|
2682
|
-
var containerEl = React.useRef();
|
|
2683
|
-
|
|
2684
|
-
var _useReducer = React.useReducer(reducer, _objectSpread2(_objectSpread2({}, initial), {}, {
|
|
2685
|
-
id: "dropdown-".concat(initId, "-").concat(new Date().getMilliseconds()),
|
|
2686
|
-
disabled: disabled,
|
|
2687
|
-
focused: initFocused
|
|
2688
|
-
})),
|
|
2689
|
-
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
2690
|
-
state = _useReducer2[0],
|
|
2691
|
-
dispatch = _useReducer2[1];
|
|
2692
|
-
|
|
2693
|
-
var focused = state.focused,
|
|
2694
|
-
visible = state.visible,
|
|
2695
|
-
activeIndex = state.activeIndex,
|
|
2696
|
-
id = state.id;
|
|
2697
|
-
var onSelect_ = createOnSelect(state, dispatch, onSelect);
|
|
2698
|
-
var selectedOption = options.find(function (o) {
|
|
2699
|
-
return o.value === value;
|
|
2700
|
-
});
|
|
2701
|
-
return /*#__PURE__*/React__default['default'].createElement(DropdownContainer$1, {
|
|
2702
|
-
className: className || 'lunatic-dropdown',
|
|
2703
|
-
ref: containerEl,
|
|
2704
|
-
state: state,
|
|
2705
|
-
dispatch: dispatch,
|
|
2706
|
-
options: options,
|
|
2707
|
-
response: response,
|
|
2708
|
-
management: management,
|
|
2709
|
-
label: label,
|
|
2710
|
-
labelPosition: labelPosition,
|
|
2711
|
-
mandatory: mandatory,
|
|
2712
|
-
onSelect: onSelect_,
|
|
2713
|
-
value: value,
|
|
2714
|
-
zIndex: zIndex
|
|
2715
|
-
}, /*#__PURE__*/React__default['default'].createElement("span", {
|
|
2716
|
-
className: classnames('lunatic-dropdown-input', {
|
|
2717
|
-
focused: focused
|
|
2718
|
-
})
|
|
2719
|
-
}, /*#__PURE__*/React__default['default'].createElement("input", {
|
|
2720
|
-
type: "button",
|
|
2721
|
-
disabled: disabled,
|
|
2722
|
-
value: selectedOption ? selectedOption.label : placeholder || ''
|
|
2723
|
-
})), getIcon(state, dispatch)(visible, containerEl), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
2724
|
-
tabIndex: "-1",
|
|
2725
|
-
className: classnames('lunatic-transition', {
|
|
2726
|
-
visible: isDisplay(state),
|
|
2727
|
-
'width-auto': widthAuto
|
|
2728
|
-
})
|
|
2729
|
-
}, /*#__PURE__*/React__default['default'].createElement(Panel, {
|
|
2730
|
-
idDropdown: id,
|
|
2731
|
-
options: options,
|
|
2732
|
-
display: isDisplay(state),
|
|
2733
|
-
activeIndex: activeIndex,
|
|
2734
|
-
optionComponent: Option,
|
|
2735
|
-
selectedOption: selectedOption,
|
|
2736
|
-
onSelect: onSelect_,
|
|
2737
|
-
handleActive: function handleActive(index) {
|
|
2738
|
-
return dispatch(setActiveOption(index));
|
|
2739
|
-
}
|
|
2740
|
-
})));
|
|
2741
|
-
};
|
|
2742
|
-
|
|
2743
|
-
Dropdown$1.propTypes = {
|
|
2744
|
-
widthAuto: PropTypes__default['default'].bool,
|
|
2745
|
-
disabled: PropTypes__default['default'].bool,
|
|
2746
|
-
focused: PropTypes__default['default'].bool,
|
|
2747
|
-
zIndex: PropTypes__default['default'].number,
|
|
2748
|
-
className: PropTypes__default['default'].string,
|
|
2749
|
-
id: PropTypes__default['default'].string,
|
|
2750
|
-
options: PropTypes__default['default'].array.isRequired,
|
|
2751
|
-
onSelect: PropTypes__default['default'].func,
|
|
2752
|
-
placeholder: PropTypes__default['default'].string,
|
|
2753
|
-
value: PropTypes__default['default'].oneOfType([PropTypes__default['default'].string, PropTypes__default['default'].number, PropTypes__default['default'].bool])
|
|
2754
|
-
};
|
|
2755
|
-
Dropdown$1.defaultProps = {
|
|
2756
|
-
disabled: false,
|
|
2757
|
-
focused: false,
|
|
2758
|
-
options: [],
|
|
2759
|
-
zIndex: 0,
|
|
2760
|
-
onSelect: function onSelect() {
|
|
2761
|
-
return null;
|
|
2762
|
-
},
|
|
2763
|
-
placeholder: 'Search...',
|
|
2764
|
-
widthAuto: false
|
|
2765
|
-
};
|
|
2766
|
-
/* **/
|
|
2767
|
-
|
|
2768
|
-
var isDisplay = function isDisplay(_ref2) {
|
|
2769
|
-
var visible = _ref2.visible,
|
|
2770
|
-
options = _ref2.options;
|
|
2771
|
-
return visible && options.length > 0;
|
|
2772
|
-
};
|
|
2773
|
-
/** */
|
|
2774
|
-
|
|
2775
|
-
|
|
2776
|
-
var getIcon = function getIcon(_ref3, dispatch) {
|
|
2777
|
-
var disabled = _ref3.disabled;
|
|
2778
|
-
return function (visible, containerEl) {
|
|
2779
|
-
if (disabled) {
|
|
2780
|
-
return /*#__PURE__*/React__default['default'].createElement("span", {
|
|
2781
|
-
className: "lunatic-icone"
|
|
2782
|
-
}, /*#__PURE__*/React__default['default'].createElement(Icon, {
|
|
2783
|
-
width: 10,
|
|
2784
|
-
height: 10
|
|
2785
|
-
}));
|
|
2786
|
-
}
|
|
2787
|
-
|
|
2788
|
-
return /*#__PURE__*/React__default['default'].createElement("span", {
|
|
2789
|
-
className: "lunatic-icone",
|
|
2790
|
-
tabIndex: "-1",
|
|
2791
|
-
onMouseDown: function onMouseDown(e) {
|
|
2792
|
-
e.stopPropagation();
|
|
2793
|
-
e.preventDefault();
|
|
2794
|
-
|
|
2795
|
-
if (visible) {
|
|
2796
|
-
dispatch(hidePanel());
|
|
2797
|
-
} else {
|
|
2798
|
-
dispatch(showPanel());
|
|
2799
|
-
containerEl.current.focus();
|
|
2800
|
-
}
|
|
2801
|
-
}
|
|
2802
|
-
}, visible ? /*#__PURE__*/React__default['default'].createElement(Icon$1, {
|
|
2803
|
-
width: 10,
|
|
2804
|
-
height: 10
|
|
2805
|
-
}) : /*#__PURE__*/React__default['default'].createElement(Icon, {
|
|
2806
|
-
width: 10,
|
|
2807
|
-
height: 10
|
|
2808
|
-
}));
|
|
2809
|
-
};
|
|
2810
|
-
};
|
|
2811
|
-
|
|
2812
|
-
var createOnSelect = function createOnSelect(_, dispatch, onSelect) {
|
|
2813
|
-
return function (option) {
|
|
2814
|
-
dispatch(setSelectedOption(option));
|
|
2815
|
-
dispatch(hidePanel());
|
|
2816
|
-
onSelect(option);
|
|
2817
|
-
};
|
|
2818
|
-
};
|
|
2819
|
-
|
|
2820
|
-
var childrenToOption = function childrenToOption() {
|
|
2821
|
-
var children = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
2822
|
-
return (Array.isArray(children) ? children : [children]).map(function (child) {
|
|
2823
|
-
var value = child.props.value;
|
|
2824
|
-
var label = child.props.children;
|
|
2825
|
-
|
|
2826
|
-
if (label === undefined || value === undefined) {
|
|
2827
|
-
throw new Error('Ooops');
|
|
2828
|
-
}
|
|
2829
|
-
|
|
2830
|
-
return {
|
|
2831
|
-
label: label,
|
|
2832
|
-
value: value
|
|
2833
|
-
};
|
|
2834
|
-
});
|
|
2835
|
-
};
|
|
2836
|
-
|
|
2837
|
-
var createDropdown = function createDropdown(Component) {
|
|
2838
|
-
return function (_ref) {
|
|
2839
|
-
var children = _ref.children,
|
|
2840
|
-
options = _ref.options,
|
|
2841
|
-
props = _objectWithoutProperties(_ref, ["children", "options"]);
|
|
2842
|
-
|
|
2843
|
-
var o = options || childrenToOption(children);
|
|
2844
|
-
return /*#__PURE__*/React__default['default'].createElement(Component, _extends({
|
|
2845
|
-
options: o
|
|
2846
|
-
}, props));
|
|
2847
|
-
};
|
|
2848
|
-
};
|
|
2849
|
-
|
|
2850
|
-
var DropdownSimple = createDropdown(Dropdown$1);
|
|
2851
|
-
|
|
2852
|
-
var Option$1 = (function (_ref) {
|
|
2853
|
-
var label = _ref.label,
|
|
2854
|
-
active = _ref.active,
|
|
2855
|
-
prefix = _ref.prefix,
|
|
2856
|
-
selected = _ref.selected;
|
|
2857
|
-
var initLetters = lettersMatching(label, prefix);
|
|
2858
|
-
var what = label.split('').reduce(function (_ref2, c) {
|
|
2859
|
-
var letters = _ref2.letters,
|
|
2860
|
-
stack = _ref2.stack;
|
|
2861
|
-
var m = preparePrefix(c);
|
|
2862
|
-
|
|
2863
|
-
var _letters = _toArray(letters),
|
|
2864
|
-
first = _letters[0],
|
|
2865
|
-
rest = _letters.slice(1);
|
|
2866
|
-
|
|
2867
|
-
if (m === first) {
|
|
2868
|
-
return {
|
|
2869
|
-
letters: rest,
|
|
2870
|
-
stack: [].concat(_toConsumableArray(stack), [{
|
|
2871
|
-
"char": c,
|
|
2872
|
-
className: 'lunatic-prefix'
|
|
2873
|
-
}])
|
|
2874
|
-
};
|
|
2875
|
-
}
|
|
2876
|
-
|
|
2877
|
-
return {
|
|
2878
|
-
letters: letters,
|
|
2879
|
-
stack: [].concat(_toConsumableArray(stack), [{
|
|
2880
|
-
"char": c,
|
|
2881
|
-
className: 'lunatic-normal'
|
|
2882
|
-
}])
|
|
2883
|
-
};
|
|
2884
|
-
}, {
|
|
2885
|
-
letters: initLetters,
|
|
2886
|
-
stack: []
|
|
2887
|
-
}).stack.reduce(function (_ref3, _ref4) {
|
|
2888
|
-
var last = _ref3.last,
|
|
2889
|
-
stack = _ref3.stack;
|
|
2890
|
-
var _char = _ref4["char"],
|
|
2891
|
-
className = _ref4.className;
|
|
2892
|
-
|
|
2893
|
-
if (!last) {
|
|
2894
|
-
return {
|
|
2895
|
-
last: className,
|
|
2896
|
-
stack: [{
|
|
2897
|
-
part: _char,
|
|
2898
|
-
className: className
|
|
2899
|
-
}]
|
|
2900
|
-
};
|
|
2901
|
-
}
|
|
2902
|
-
|
|
2903
|
-
if (last !== className) {
|
|
2904
|
-
return {
|
|
2905
|
-
last: className,
|
|
2906
|
-
stack: [{
|
|
2907
|
-
part: _char,
|
|
2908
|
-
className: className
|
|
2909
|
-
}].concat(_toConsumableArray(stack))
|
|
2910
|
-
};
|
|
2911
|
-
}
|
|
2912
|
-
|
|
2913
|
-
var _stack = _toArray(stack),
|
|
2914
|
-
first = _stack[0],
|
|
2915
|
-
rest = _stack.slice(1);
|
|
2916
|
-
|
|
2917
|
-
return {
|
|
2918
|
-
last: className,
|
|
2919
|
-
stack: [_objectSpread2(_objectSpread2({}, first), {}, {
|
|
2920
|
-
part: "".concat(first.part).concat(_char)
|
|
2921
|
-
})].concat(_toConsumableArray(rest))
|
|
2922
|
-
};
|
|
2923
|
-
}, {
|
|
2924
|
-
last: undefined,
|
|
2925
|
-
stack: []
|
|
2926
|
-
}).stack.reverse().map(function (_ref5, i) {
|
|
2927
|
-
var part = _ref5.part,
|
|
2928
|
-
className = _ref5.className;
|
|
2929
|
-
return /*#__PURE__*/React__default['default'].createElement("span", {
|
|
2930
|
-
className: className,
|
|
2931
|
-
key: i
|
|
2932
|
-
}, part);
|
|
2933
|
-
});
|
|
2934
|
-
return /*#__PURE__*/React__default['default'].createElement("span", {
|
|
2935
|
-
className: classnames('lunatic-dropdown-option', {
|
|
2936
|
-
'lunatic-dropdown-option-active': active,
|
|
2937
|
-
'lunatic-dropdown-option-selected': selected
|
|
2938
|
-
})
|
|
2939
|
-
}, what);
|
|
2940
|
-
});
|
|
2941
|
-
|
|
2942
|
-
var CrossIcon = (function (_ref) {
|
|
2943
|
-
var _ref$width = _ref.width,
|
|
2944
|
-
width = _ref$width === void 0 ? 20 : _ref$width,
|
|
2945
|
-
_ref$height = _ref.height,
|
|
2946
|
-
height = _ref$height === void 0 ? 20 : _ref$height,
|
|
2947
|
-
_ref$color = _ref.color,
|
|
2948
|
-
color = _ref$color === void 0 ? "#aaa" : _ref$color;
|
|
2949
|
-
return /*#__PURE__*/React__default['default'].createElement("svg", {
|
|
2950
|
-
xmlns: "http://www.w3.org/2000/svg",
|
|
2951
|
-
width: width,
|
|
2952
|
-
height: height,
|
|
2953
|
-
x: "0",
|
|
2954
|
-
y: "0",
|
|
2955
|
-
enableBackground: "new 0 0 612 612",
|
|
2956
|
-
version: "1.1",
|
|
2957
|
-
viewBox: "0 0 612 612",
|
|
2958
|
-
xmlSpace: "preserve"
|
|
2959
|
-
}, /*#__PURE__*/React__default['default'].createElement("path", {
|
|
2960
|
-
fill: color,
|
|
2961
|
-
d: "M444.644 306l138.644-138.644c38.284-38.284 38.284-100.36 0-138.644-38.283-38.284-100.359-38.284-138.644 0L306 167.356 167.356 28.713c-38.284-38.284-100.36-38.284-138.644 0s-38.284 100.36 0 138.644L167.356 306 28.713 444.644c-38.284 38.283-38.284 100.36 0 138.644 38.284 38.284 100.36 38.284 138.644 0L306 444.644l138.644 138.644c38.283 38.284 100.36 38.284 138.644 0 38.284-38.283 38.284-100.36 0-138.644L444.644 306z"
|
|
2962
|
-
}));
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
2963
5
|
});
|
|
2964
|
-
|
|
2965
|
-
|
|
2966
|
-
|
|
2967
|
-
var getIcon$1 = function getIcon(visible) {
|
|
2968
|
-
return visible ? /*#__PURE__*/React__default['default'].createElement(Icon$1, {
|
|
2969
|
-
width: 10,
|
|
2970
|
-
height: 10
|
|
2971
|
-
}) : /*#__PURE__*/React__default['default'].createElement(Icon, {
|
|
2972
|
-
width: 10,
|
|
2973
|
-
height: 10
|
|
2974
|
-
});
|
|
6
|
+
var _exportNames = {
|
|
7
|
+
useLunatic: true
|
|
2975
8
|
};
|
|
2976
|
-
|
|
2977
|
-
|
|
2978
|
-
|
|
2979
|
-
|
|
2980
|
-
disabled = _ref.disabled,
|
|
2981
|
-
onDelete = _ref.onDelete,
|
|
2982
|
-
onSwitch = _ref.onSwitch;
|
|
2983
|
-
|
|
2984
|
-
if (disabled) {
|
|
2985
|
-
return /*#__PURE__*/React__default['default'].createElement("span", {
|
|
2986
|
-
className: "lunatic-icone",
|
|
2987
|
-
tabIndex: "-1",
|
|
2988
|
-
onMouseDown: onSwitch
|
|
2989
|
-
}, /*#__PURE__*/React__default['default'].createElement(Icon, {
|
|
2990
|
-
width: 10,
|
|
2991
|
-
height: 10
|
|
2992
|
-
}));
|
|
9
|
+
Object.defineProperty(exports, "useLunatic", {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function get() {
|
|
12
|
+
return _useLunatic["default"];
|
|
2993
13
|
}
|
|
2994
|
-
|
|
2995
|
-
return prefix && prefix.length > 0 ? /*#__PURE__*/React__default['default'].createElement("span", {
|
|
2996
|
-
className: "lunatic-icone",
|
|
2997
|
-
tabIndex: "-1",
|
|
2998
|
-
onMouseDown: onDelete
|
|
2999
|
-
}, /*#__PURE__*/React__default['default'].createElement(CrossIcon, {
|
|
3000
|
-
width: 10,
|
|
3001
|
-
height: 10
|
|
3002
|
-
})) : /*#__PURE__*/React__default['default'].createElement("span", {
|
|
3003
|
-
className: "lunatic-icone",
|
|
3004
|
-
tabIndex: "-1",
|
|
3005
|
-
onMouseDown: onSwitch
|
|
3006
|
-
}, getIcon$1(visible));
|
|
3007
|
-
};
|
|
3008
|
-
|
|
3009
|
-
/* **/
|
|
3010
|
-
|
|
3011
|
-
var isDisplay$1 = function isDisplay(_ref) {
|
|
3012
|
-
var visible = _ref.visible,
|
|
3013
|
-
visibleOptions = _ref.visibleOptions;
|
|
3014
|
-
return visible && visibleOptions.length > 0;
|
|
3015
|
-
};
|
|
3016
|
-
/** */
|
|
3017
|
-
|
|
3018
|
-
|
|
3019
|
-
var onChangeCallback = function onChangeCallback(state, dispatch) {
|
|
3020
|
-
return function (e) {
|
|
3021
|
-
e.stopPropagation();
|
|
3022
|
-
e.preventDefault();
|
|
3023
|
-
dispatch(setValue(e.target.value));
|
|
3024
|
-
dispatch(setPrefix(preparePrefix(e.target.value)));
|
|
3025
|
-
};
|
|
3026
|
-
};
|
|
3027
|
-
/** */
|
|
3028
|
-
|
|
3029
|
-
|
|
3030
|
-
var createOnSelect$1 = function createOnSelect(_, dispatch, onSelect) {
|
|
3031
|
-
return function (option) {
|
|
3032
|
-
dispatch(setSelectedOption(option));
|
|
3033
|
-
dispatch(hidePanel());
|
|
3034
|
-
onSelect(option);
|
|
3035
|
-
};
|
|
3036
|
-
};
|
|
3037
|
-
/**
|
|
3038
|
-
*
|
|
3039
|
-
* @param {props}
|
|
3040
|
-
*/
|
|
3041
|
-
|
|
3042
|
-
|
|
3043
|
-
function Dropdown$2(_ref2) {
|
|
3044
|
-
var widthAuto = _ref2.widthAuto,
|
|
3045
|
-
_ref2$options = _ref2.options,
|
|
3046
|
-
options = _ref2$options === void 0 ? [] : _ref2$options,
|
|
3047
|
-
onSelect = _ref2.onSelect,
|
|
3048
|
-
response = _ref2.response,
|
|
3049
|
-
className = _ref2.className,
|
|
3050
|
-
placeholder = _ref2.placeholder,
|
|
3051
|
-
label = _ref2.label,
|
|
3052
|
-
labelPosition = _ref2.labelPosition,
|
|
3053
|
-
mandatory = _ref2.mandatory,
|
|
3054
|
-
valueFromProps = _ref2.value,
|
|
3055
|
-
zIndex = _ref2.zIndex,
|
|
3056
|
-
management = _ref2.management,
|
|
3057
|
-
disabled = _ref2.disabled,
|
|
3058
|
-
initFocused = _ref2.focused;
|
|
3059
|
-
|
|
3060
|
-
var _useReducer = React.useReducer(reducer, _objectSpread2(_objectSpread2({}, initial), {}, {
|
|
3061
|
-
id: "dropdown-".concat(new Date().getMilliseconds()),
|
|
3062
|
-
disabled: disabled,
|
|
3063
|
-
focused: initFocused
|
|
3064
|
-
})),
|
|
3065
|
-
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
3066
|
-
state = _useReducer2[0],
|
|
3067
|
-
dispatch = _useReducer2[1];
|
|
3068
|
-
|
|
3069
|
-
var prefix = state.prefix,
|
|
3070
|
-
visible = state.visible,
|
|
3071
|
-
activeIndex = state.activeIndex,
|
|
3072
|
-
visibleOptions = state.visibleOptions,
|
|
3073
|
-
value = state.value,
|
|
3074
|
-
focused = state.focused,
|
|
3075
|
-
id = state.id;
|
|
3076
|
-
var inputEl = React.useRef();
|
|
3077
|
-
var containerEl = React.useRef();
|
|
3078
|
-
var onSelect_ = createOnSelect$1(state, dispatch, onSelect);
|
|
3079
|
-
var selectedOption = options.find(function (o) {
|
|
3080
|
-
return o.value === value;
|
|
3081
|
-
});
|
|
3082
|
-
React.useEffect(function () {
|
|
3083
|
-
var current = inputEl.current;
|
|
3084
|
-
|
|
3085
|
-
if (current && focused) {
|
|
3086
|
-
current.focus();
|
|
3087
|
-
}
|
|
3088
|
-
}, [inputEl, focused]);
|
|
3089
|
-
return /*#__PURE__*/React__default['default'].createElement(DropdownContainer$1, {
|
|
3090
|
-
className: className || 'lunatic-dropdown',
|
|
3091
|
-
state: state,
|
|
3092
|
-
ref: containerEl,
|
|
3093
|
-
dispatch: dispatch,
|
|
3094
|
-
options: options,
|
|
3095
|
-
label: label,
|
|
3096
|
-
labelPosition: labelPosition,
|
|
3097
|
-
mandatory: mandatory,
|
|
3098
|
-
response: response,
|
|
3099
|
-
onSelect: onSelect_,
|
|
3100
|
-
value: valueFromProps,
|
|
3101
|
-
zIndex: zIndex,
|
|
3102
|
-
management: management
|
|
3103
|
-
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
3104
|
-
className: classnames('lunatic-dropdown-input', {
|
|
3105
|
-
focused: focused,
|
|
3106
|
-
disabled: disabled
|
|
3107
|
-
})
|
|
3108
|
-
}, /*#__PURE__*/React__default['default'].createElement("input", {
|
|
3109
|
-
type: "text",
|
|
3110
|
-
ref: inputEl,
|
|
3111
|
-
value: value || '',
|
|
3112
|
-
disabled: disabled,
|
|
3113
|
-
placeholder: placeholder,
|
|
3114
|
-
autoComplete: "list",
|
|
3115
|
-
autoCorrect: "off",
|
|
3116
|
-
autoCapitalize: "off",
|
|
3117
|
-
spellCheck: "false",
|
|
3118
|
-
tabIndex: "-1",
|
|
3119
|
-
onChange: onChangeCallback(state, dispatch)
|
|
3120
|
-
})), /*#__PURE__*/React__default['default'].createElement(Icone, {
|
|
3121
|
-
prefix: prefix,
|
|
3122
|
-
visible: visible,
|
|
3123
|
-
disabled: disabled,
|
|
3124
|
-
onDelete: function onDelete(e) {
|
|
3125
|
-
e.stopPropagation();
|
|
3126
|
-
inputEl.current.value = '';
|
|
3127
|
-
dispatch(resetSelection());
|
|
3128
|
-
onSelect_({
|
|
3129
|
-
value: null
|
|
3130
|
-
});
|
|
3131
|
-
},
|
|
3132
|
-
onSwitch: function onSwitch(e) {
|
|
3133
|
-
e.stopPropagation();
|
|
3134
|
-
e.preventDefault();
|
|
3135
|
-
|
|
3136
|
-
if (visible) {
|
|
3137
|
-
dispatch(hidePanel());
|
|
3138
|
-
} else {
|
|
3139
|
-
dispatch(showPanel());
|
|
3140
|
-
containerEl.current.focus();
|
|
3141
|
-
}
|
|
3142
|
-
}
|
|
3143
|
-
}), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
3144
|
-
tabIndex: "-1",
|
|
3145
|
-
className: classnames('lunatic-transition', {
|
|
3146
|
-
visible: isDisplay$1(state),
|
|
3147
|
-
'width-auto': widthAuto
|
|
3148
|
-
})
|
|
3149
|
-
}, /*#__PURE__*/React__default['default'].createElement(Panel, {
|
|
3150
|
-
idDropdown: id,
|
|
3151
|
-
options: visibleOptions,
|
|
3152
|
-
display: isDisplay$1(state) && !disabled,
|
|
3153
|
-
prefix: prefix,
|
|
3154
|
-
activeIndex: activeIndex,
|
|
3155
|
-
optionComponent: Option$1,
|
|
3156
|
-
selectedOption: selectedOption,
|
|
3157
|
-
onSelect: onSelect_,
|
|
3158
|
-
handleActive: function handleActive(index) {
|
|
3159
|
-
return dispatch(setActiveOption(index));
|
|
3160
|
-
}
|
|
3161
|
-
})));
|
|
3162
|
-
}
|
|
3163
|
-
|
|
3164
|
-
Dropdown$2.propTypes = {
|
|
3165
|
-
widthAuto: PropTypes__default['default'].bool,
|
|
3166
|
-
zIndex: PropTypes__default['default'].number,
|
|
3167
|
-
disabled: PropTypes__default['default'].bool,
|
|
3168
|
-
focused: PropTypes__default['default'].bool,
|
|
3169
|
-
className: PropTypes__default['default'].string,
|
|
3170
|
-
id: PropTypes__default['default'].string,
|
|
3171
|
-
options: PropTypes__default['default'].array.isRequired,
|
|
3172
|
-
onSelect: PropTypes__default['default'].func,
|
|
3173
|
-
placeholder: PropTypes__default['default'].string,
|
|
3174
|
-
value: PropTypes__default['default'].oneOfType([PropTypes__default['default'].string, PropTypes__default['default'].number, PropTypes__default['default'].bool])
|
|
3175
|
-
};
|
|
3176
|
-
Dropdown$2.defaultProps = {
|
|
3177
|
-
options: [],
|
|
3178
|
-
zIndex: 0,
|
|
3179
|
-
onSelect: function onSelect() {
|
|
3180
|
-
return null;
|
|
3181
|
-
},
|
|
3182
|
-
placeholder: 'Search...',
|
|
3183
|
-
disabled: false,
|
|
3184
|
-
focused: false,
|
|
3185
|
-
widthAuto: false
|
|
3186
|
-
};
|
|
3187
|
-
|
|
3188
|
-
var childrenToOption$1 = (function () {
|
|
3189
|
-
var children = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
3190
|
-
return (Array.isArray(children) ? children : [children]).map(function (child) {
|
|
3191
|
-
var value = child.props.value;
|
|
3192
|
-
var label = child.props.children;
|
|
3193
|
-
|
|
3194
|
-
if (label === undefined || value === undefined) {
|
|
3195
|
-
throw new Error("Ooops");
|
|
3196
|
-
}
|
|
3197
|
-
|
|
3198
|
-
return {
|
|
3199
|
-
label: label,
|
|
3200
|
-
value: value
|
|
3201
|
-
};
|
|
3202
|
-
});
|
|
3203
14
|
});
|
|
3204
15
|
|
|
3205
|
-
var
|
|
3206
|
-
return function (_ref) {
|
|
3207
|
-
var children = _ref.children,
|
|
3208
|
-
options = _ref.options,
|
|
3209
|
-
props = _objectWithoutProperties(_ref, ["children", "options"]);
|
|
3210
|
-
|
|
3211
|
-
var o = options || childrenToOption$1(children);
|
|
3212
|
-
return /*#__PURE__*/React__default['default'].createElement(Component, _extends({
|
|
3213
|
-
options: o
|
|
3214
|
-
}, props));
|
|
3215
|
-
};
|
|
3216
|
-
};
|
|
3217
|
-
|
|
3218
|
-
var DropdownEdit = createDropDown(Dropdown$2);
|
|
3219
|
-
|
|
3220
|
-
var css_248z$6 = "* {\n box-sizing: border-box;\n}\n\n.mandatory:after {\n content: \" *\";\n color: red;\n}\n\n.horizontal-options {\n display: inline-block;\n margin-right: 2em;\n}\n\nlabel,\n.lunatic-dropdown-label {\n margin-bottom: 0.5em;\n}\n\n.label-top {\n display: flex;\n flex-direction: column;\n}\n\n.label-bottom {\n display: flex;\n flex-direction: column-reverse;\n}\n\n.label-right {\n justify-content: flex-end;\n display: flex;\n flex-direction: row-reverse;\n align-items: baseline;\n}\n.label-right :first-child {\n margin-right: 1rem;\n}\n\n.label-left {\n display: flex;\n flex-direction: row;\n align-items: baseline;\n}\n.label-left :first-child {\n margin-right: 1rem;\n}\n\n.field-container {\n display: flex;\n}\n\n.tooltip {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n.field-with-tooltip {\n width: calc(100% - 25px);\n position: relative;\n}\n\n.field {\n width: 100%;\n position: relative;\n}\n\n.lunatic .lunatic-dropdown {\n display: block;\n width: 100%;\n}\n.lunatic .lunatic-dropdown:focus {\n outline: none;\n}\n.lunatic .lunatic-dropdown.label-left {\n display: flex;\n flex-direction: row;\n}\n.lunatic .lunatic-dropdown.label-right {\n display: flex;\n flex-direction: row-reverse;\n}\n.lunatic .lunatic-dropdown.label-top {\n display: flex;\n flex-direction: column;\n}\n.lunatic .lunatic-dropdown.label-bottom {\n display: flex;\n flex-direction: column-reverse;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-label {\n opacity: 1;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container {\n position: relative;\n height: 2em;\n width: 100%;\n z-index: 0;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container.focused {\n z-index: 1;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container:focus {\n outline: none;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container .lunatic-dropdown-content {\n background-color: lavenderblush;\n border-radius: 20px 20px;\n border-color: white;\n left: 0;\n top: 0;\n width: 100%;\n height: 100%;\n position: absolute;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container .lunatic-dropdown-content.visible {\n border-radius: 16px 16px;\n height: auto;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container .lunatic-dropdown-content.disabled {\n background-color: whitesmoke;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container .lunatic-dropdown-content .lunatic-dropdown-input {\n border-radius: 10px 10px;\n box-shadow: 0 0 0 0.2em #2a5885;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container .lunatic-dropdown-content .lunatic-dropdown-input input {\n font-family: Georgia, Times, \"Times New Roman\", serif;\n font-size: 16px;\n -moz-user-select: none;\n /* Firefox */\n -ms-user-select: none;\n /* Internet Explorer */\n -khtml-user-select: none;\n /* KHTML browsers (e.g. Konqueror) */\n -webkit-user-select: none;\n /* Chrome, Safari, and Opera */\n -webkit-touch-callout: none;\n /* Disable Android and iOS callouts*/\n margin: 0px 25px 0px 12px;\n width: calc(100% - 37px);\n background-color: transparent;\n border-color: transparent;\n height: 2em;\n border: none;\n outline: none;\n text-align: left;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container .lunatic-dropdown-content .lunatic-dropdown-input.focused {\n box-shadow: 0 0 0 0.2em #4a73a4, -5px -5px 5px #5181b8, 5px -5px 5px #5181b8, -5px 5px 5px #5181b8, 5px 5px 5px #5181b8;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container .lunatic-dropdown-content .lunatic-icone {\n cursor: pointer;\n position: absolute;\n right: 10px;\n top: 7px;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container .lunatic-dropdown-content .lunatic-icone:focus {\n outline: none;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container .lunatic-dropdown-content .lunatic-transition {\n visibility: hidden;\n overflow-y: hidden;\n opacity: 0;\n /** options style */\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container .lunatic-dropdown-content .lunatic-transition:focus {\n outline: none;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container .lunatic-dropdown-content .lunatic-transition.visible {\n visibility: visible;\n opacity: 1;\n transition: opacity 1s ease-out;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container .lunatic-dropdown-content .lunatic-transition .lunatic-dropdown-panel {\n background-color: transparent;\n margin: 0 10px 12px 10px;\n padding-top: 3px;\n list-style: none;\n max-height: 100px;\n overflow-y: auto;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container .lunatic-dropdown-content .lunatic-transition .lunatic-dropdown-panel:focus {\n outline: none;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container .lunatic-dropdown-content .lunatic-transition .lunatic-dropdown-panel::-webkit-scrollbar {\n width: 8px;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container .lunatic-dropdown-content .lunatic-transition .lunatic-dropdown-panel::-webkit-scrollbar-track {\n background-color: #4a73a4;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container .lunatic-dropdown-content .lunatic-transition .lunatic-dropdown-panel::-webkit-scrollbar-thumb {\n background: #4a73a4;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container .lunatic-dropdown-content .lunatic-transition .lunatic-dropdown-panel::-webkit-scrollbar-thumb:hover {\n background: #2a5885;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container .lunatic-dropdown-content .lunatic-transition .lunatic-dropdown-option {\n cursor: pointer;\n font-family: Georgia, Times, \"Times New Roman\", serif;\n font-size: 16px;\n white-space: nowrap;\n overflow: hidden;\n text-overflow: ellipsis;\n color: black;\n display: block;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container .lunatic-dropdown-content .lunatic-transition .lunatic-dropdown-option.lunatic-dropdown-option-active {\n color: ivory;\n background-color: #4a73a4;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container .lunatic-dropdown-content .lunatic-transition .lunatic-dropdown-option.lunatic-dropdown-option-active .lunatic-prefix {\n color: darkgoldenrod;\n font-weight: bold;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container .lunatic-dropdown-content .lunatic-transition .lunatic-dropdown-option.lunatic-dropdown-option-selected {\n color: snow;\n background-color: #881397;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container .lunatic-dropdown-content .lunatic-transition .lunatic-dropdown-option.lunatic-dropdown-option-selected .lunatic-prefix {\n color: lightgray;\n font-weight: bold;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container .lunatic-dropdown-content .lunatic-transition .lunatic-dropdown-option.lunatic-dropdown-option-selected.lunatic-dropdown-option-active {\n color: khaki;\n background-color: #bc5ac9;\n}\n.lunatic .lunatic-dropdown .lunatic-dropdown-container .lunatic-dropdown-content .lunatic-transition .lunatic-dropdown-option .lunatic-prefix {\n color: cornflowerblue;\n font-weight: bold;\n}";
|
|
3221
|
-
styleInject(css_248z$6);
|
|
3222
|
-
|
|
3223
|
-
var Dropdown$3 = function Dropdown(_ref) {
|
|
3224
|
-
var id = _ref.id,
|
|
3225
|
-
label = _ref.label,
|
|
3226
|
-
preferences = _ref.preferences,
|
|
3227
|
-
response = _ref.response,
|
|
3228
|
-
handleChange = _ref.handleChange,
|
|
3229
|
-
options = _ref.options,
|
|
3230
|
-
writable = _ref.writable,
|
|
3231
|
-
declarations = _ref.declarations,
|
|
3232
|
-
features = _ref.features,
|
|
3233
|
-
bindings = _ref.bindings,
|
|
3234
|
-
management = _ref.management,
|
|
3235
|
-
freezeOptions = _ref.freezeOptions,
|
|
3236
|
-
rest = _objectWithoutProperties(_ref, ["id", "label", "preferences", "response", "handleChange", "options", "writable", "declarations", "features", "bindings", "management", "freezeOptions"]);
|
|
3237
|
-
|
|
3238
|
-
var _useState = React.useState(options),
|
|
3239
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
3240
|
-
opts = _useState2[0],
|
|
3241
|
-
setOpts = _useState2[1];
|
|
16
|
+
var _components = require("./components");
|
|
3242
17
|
|
|
3243
|
-
|
|
3244
|
-
|
|
3245
|
-
|
|
3246
|
-
|
|
3247
|
-
|
|
3248
|
-
|
|
3249
|
-
|
|
3250
|
-
|
|
3251
|
-
}, restOpts);
|
|
3252
|
-
});
|
|
3253
|
-
setOpts(featOptions);
|
|
3254
|
-
}
|
|
3255
|
-
}, [freezeOptions, features, bindings, options]);
|
|
3256
|
-
var interpretedLabel = interpret(features)(bindings)(label);
|
|
3257
|
-
var value = getResponseByPreference(preferences)(response);
|
|
3258
|
-
|
|
3259
|
-
var onSelect = function onSelect(e) {
|
|
3260
|
-
return handleChange(_defineProperty({}, getResponseName(response), e.value));
|
|
3261
|
-
};
|
|
3262
|
-
|
|
3263
|
-
return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
3264
|
-
id: id,
|
|
3265
|
-
type: BEFORE_QUESTION_TEXT,
|
|
3266
|
-
declarations: declarations,
|
|
3267
|
-
features: features,
|
|
3268
|
-
bindings: bindings
|
|
3269
|
-
}), /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
3270
|
-
id: id,
|
|
3271
|
-
type: AFTER_QUESTION_TEXT,
|
|
3272
|
-
declarations: declarations,
|
|
3273
|
-
features: features,
|
|
3274
|
-
bindings: bindings
|
|
3275
|
-
}), writable ? /*#__PURE__*/React__default['default'].createElement(DropdownEdit, _extends({}, rest, {
|
|
3276
|
-
id: id,
|
|
3277
|
-
value: value,
|
|
3278
|
-
response: response,
|
|
3279
|
-
label: interpretedLabel,
|
|
3280
|
-
options: opts,
|
|
3281
|
-
onSelect: onSelect,
|
|
3282
|
-
management: management
|
|
3283
|
-
})) : /*#__PURE__*/React__default['default'].createElement(DropdownSimple, _extends({}, rest, {
|
|
3284
|
-
id: id,
|
|
3285
|
-
value: value,
|
|
3286
|
-
response: response,
|
|
3287
|
-
label: interpretedLabel,
|
|
3288
|
-
options: opts,
|
|
3289
|
-
onSelect: onSelect,
|
|
3290
|
-
management: management
|
|
3291
|
-
})), /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
3292
|
-
id: id,
|
|
3293
|
-
type: DETACHABLE,
|
|
3294
|
-
declarations: declarations,
|
|
3295
|
-
features: features,
|
|
3296
|
-
bindings: bindings
|
|
3297
|
-
}));
|
|
3298
|
-
};
|
|
3299
|
-
|
|
3300
|
-
Dropdown$3.propTypes = {
|
|
3301
|
-
disabled: PropTypes__default['default'].bool,
|
|
3302
|
-
writable: PropTypes__default['default'].bool,
|
|
3303
|
-
handleChange: PropTypes__default['default'].func,
|
|
3304
|
-
label: PropTypes__default['default'].string,
|
|
3305
|
-
className: PropTypes__default['default'].string,
|
|
3306
|
-
zIndex: PropTypes__default['default'].number,
|
|
3307
|
-
freezeOptions: PropTypes__default['default'].bool
|
|
3308
|
-
};
|
|
3309
|
-
Dropdown$3.defaultProps = {
|
|
3310
|
-
writable: false,
|
|
3311
|
-
handleChange: function handleChange() {
|
|
3312
|
-
return null;
|
|
3313
|
-
},
|
|
3314
|
-
label: undefined,
|
|
3315
|
-
className: undefined,
|
|
3316
|
-
zIndex: 0,
|
|
3317
|
-
disabled: false,
|
|
3318
|
-
freezeOptions: false
|
|
3319
|
-
};
|
|
3320
|
-
var component$1 = /*#__PURE__*/React__default['default'].memo(Dropdown$3, areEqual);
|
|
3321
|
-
|
|
3322
|
-
var css_248z$7 = "* {\n box-sizing: border-box;\n}\n\n.mandatory:after {\n content: \" *\";\n color: red;\n}\n\n.horizontal-options {\n display: inline-block;\n margin-right: 2em;\n}\n\nlabel,\n.lunatic-dropdown-label {\n margin-bottom: 0.5em;\n}\n\n.label-top {\n display: flex;\n flex-direction: column;\n}\n\n.label-bottom {\n display: flex;\n flex-direction: column-reverse;\n}\n\n.label-right {\n justify-content: flex-end;\n display: flex;\n flex-direction: row-reverse;\n align-items: baseline;\n}\n.label-right :first-child {\n margin-right: 1rem;\n}\n\n.label-left {\n display: flex;\n flex-direction: row;\n align-items: baseline;\n}\n.label-left :first-child {\n margin-right: 1rem;\n}\n\n.field-container {\n display: flex;\n}\n\n.tooltip {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n.field-with-tooltip {\n width: calc(100% - 25px);\n position: relative;\n}\n\n.field {\n width: 100%;\n position: relative;\n}\n\n.input-lunatic {\n box-sizing: border-box;\n border: solid 2px #e80a4d;\n border-radius: 10px;\n padding: 5px;\n}\n.input-lunatic:focus {\n outline: none;\n box-shadow: 0 0 10px #e80a4d;\n}\n.input-lunatic:read-only {\n background-color: #ebebe4;\n}\n\n.warning {\n box-sizing: border-box;\n border: solid 2px #f50c0c;\n background-color: #f50c0c;\n}\n\n.lunatic-input-number-errors .error {\n color: #f50c0c;\n}";
|
|
3323
|
-
styleInject(css_248z$7);
|
|
3324
|
-
|
|
3325
|
-
var Input = function Input(props) {
|
|
3326
|
-
return /*#__PURE__*/React__default['default'].createElement(InputDeclarationsWrapper, _extends({
|
|
3327
|
-
type: "text",
|
|
3328
|
-
roleType: "input"
|
|
3329
|
-
}, props));
|
|
3330
|
-
};
|
|
3331
|
-
|
|
3332
|
-
var input = /*#__PURE__*/React__default['default'].memo(Input, areEqual);
|
|
3333
|
-
|
|
3334
|
-
var InputNumber = function InputNumber(_ref) {
|
|
3335
|
-
var id = _ref.id,
|
|
3336
|
-
label = _ref.label,
|
|
3337
|
-
preferences = _ref.preferences,
|
|
3338
|
-
response = _ref.response,
|
|
3339
|
-
min = _ref.min,
|
|
3340
|
-
max = _ref.max,
|
|
3341
|
-
decimals = _ref.decimals,
|
|
3342
|
-
placeholder = _ref.placeholder,
|
|
3343
|
-
handleChange = _ref.handleChange,
|
|
3344
|
-
readOnly = _ref.readOnly,
|
|
3345
|
-
disabled = _ref.disabled,
|
|
3346
|
-
autoComplete = _ref.autoComplete,
|
|
3347
|
-
focused = _ref.focused,
|
|
3348
|
-
style = _ref.style,
|
|
3349
|
-
unit = _ref.unit,
|
|
3350
|
-
labelPosition = _ref.labelPosition,
|
|
3351
|
-
unitPosition = _ref.unitPosition,
|
|
3352
|
-
declarations = _ref.declarations,
|
|
3353
|
-
features = _ref.features,
|
|
3354
|
-
bindings = _ref.bindings,
|
|
3355
|
-
management = _ref.management,
|
|
3356
|
-
mandatory = _ref.mandatory,
|
|
3357
|
-
validators = _ref.validators;
|
|
3358
|
-
var inputRef = React.useRef();
|
|
3359
|
-
|
|
3360
|
-
var _useState = React.useState(function () {
|
|
3361
|
-
return getResponseByPreference(preferences)(response);
|
|
3362
|
-
}),
|
|
3363
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
3364
|
-
value = _useState2[0],
|
|
3365
|
-
setValue = _useState2[1];
|
|
3366
|
-
|
|
3367
|
-
var _useState3 = React.useState([minMaxValidator({
|
|
3368
|
-
min: min,
|
|
3369
|
-
max: max
|
|
3370
|
-
})].concat(_toConsumableArray(validators)).map(function (v) {
|
|
3371
|
-
return v(value);
|
|
3372
|
-
}).filter(function (m) {
|
|
3373
|
-
return m !== undefined;
|
|
3374
|
-
})),
|
|
3375
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
3376
|
-
messagesError = _useState4[0],
|
|
3377
|
-
setMessagesError = _useState4[1]; // Assume we only want to handle enable external updates
|
|
3378
|
-
// Don't need to check all value changes
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
React.useEffect(function () {
|
|
3382
|
-
if (getResponseByPreference(preferences)(response) !== value) setValue(getResponseByPreference(preferences)(response)); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3383
|
-
}, [response, preferences]);
|
|
3384
|
-
|
|
3385
|
-
var handleChangeOnBlur = function handleChangeOnBlur() {
|
|
3386
|
-
handleChange(_defineProperty({}, getResponseName(response), value));
|
|
3387
|
-
};
|
|
3388
|
-
|
|
3389
|
-
var validate = function validate(v) {
|
|
3390
|
-
setMessagesError([minMaxValidator({
|
|
3391
|
-
min: min,
|
|
3392
|
-
max: max
|
|
3393
|
-
})].concat(_toConsumableArray(validators)).map(function (f) {
|
|
3394
|
-
return f(v);
|
|
3395
|
-
}).filter(function (m) {
|
|
3396
|
-
return m !== undefined;
|
|
3397
|
-
}));
|
|
3398
|
-
};
|
|
3399
|
-
|
|
3400
|
-
React.useEffect(function () {
|
|
3401
|
-
if (focused) inputRef.current.focus();
|
|
3402
|
-
}, [focused]);
|
|
3403
|
-
React.useEffect(function () {
|
|
3404
|
-
setMessagesError([minMaxValidator({
|
|
3405
|
-
min: min,
|
|
3406
|
-
max: max
|
|
3407
|
-
})].concat(_toConsumableArray(validators)).map(function (v) {
|
|
3408
|
-
return v(value);
|
|
3409
|
-
}).filter(function (m) {
|
|
3410
|
-
return m !== undefined;
|
|
3411
|
-
}));
|
|
3412
|
-
}, [value, min, max, validators]);
|
|
3413
|
-
return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
3414
|
-
id: id,
|
|
3415
|
-
type: BEFORE_QUESTION_TEXT,
|
|
3416
|
-
declarations: declarations,
|
|
3417
|
-
features: features,
|
|
3418
|
-
bindings: bindings
|
|
3419
|
-
}), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
3420
|
-
className: getLabelPositionClass(labelPosition)
|
|
3421
|
-
}, /*#__PURE__*/React__default['default'].createElement("label", {
|
|
3422
|
-
htmlFor: "input-".concat(id),
|
|
3423
|
-
id: "input-label-".concat(id),
|
|
3424
|
-
className: "".concat(mandatory ? 'mandatory' : '')
|
|
3425
|
-
}, interpret(features)(bindings)(label), ' ', /*#__PURE__*/React__default['default'].createElement("span", {
|
|
3426
|
-
className: "unit"
|
|
3427
|
-
}, unit && ['DEFAULT', 'BEFORE'].includes(unitPosition) ? "(".concat(unit, ")") : '')), /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
3428
|
-
id: id,
|
|
3429
|
-
type: AFTER_QUESTION_TEXT,
|
|
3430
|
-
declarations: declarations,
|
|
3431
|
-
features: features,
|
|
3432
|
-
bindings: bindings
|
|
3433
|
-
}), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
3434
|
-
className: "field-container"
|
|
3435
|
-
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
3436
|
-
className: "".concat(management ? 'field-with-tooltip' : 'field')
|
|
3437
|
-
}, /*#__PURE__*/React__default['default'].createElement("input", {
|
|
3438
|
-
type: "number",
|
|
3439
|
-
id: "input-".concat(id),
|
|
3440
|
-
ref: inputRef,
|
|
3441
|
-
"aria-labelledby": "input-label-".concat(id),
|
|
3442
|
-
value: value || '',
|
|
3443
|
-
min: min,
|
|
3444
|
-
max: max,
|
|
3445
|
-
step: decimals ? "".concat(Math.pow(10, -decimals)) : '0',
|
|
3446
|
-
placeholder: placeholder,
|
|
3447
|
-
className: "input-lunatic ".concat(messagesError.length > 0 ? 'warning' : ''),
|
|
3448
|
-
style: buildStyleObject(style),
|
|
3449
|
-
readOnly: readOnly,
|
|
3450
|
-
disabled: disabled,
|
|
3451
|
-
autoComplete: autoComplete ? 'on' : 'off',
|
|
3452
|
-
required: mandatory,
|
|
3453
|
-
"aria-required": mandatory,
|
|
3454
|
-
onChange: function onChange(_ref2) {
|
|
3455
|
-
var v = _ref2.target.value;
|
|
3456
|
-
validate(v);
|
|
3457
|
-
if (management) setValue(v);else setValue(v === '' ? null : v);
|
|
3458
|
-
},
|
|
3459
|
-
onBlur: handleChangeOnBlur
|
|
3460
|
-
}), unitPosition === 'AFTER' && /*#__PURE__*/React__default['default'].createElement("span", {
|
|
3461
|
-
className: "unit"
|
|
3462
|
-
}, unit)), management && /*#__PURE__*/React__default['default'].createElement("div", {
|
|
3463
|
-
className: "tooltip"
|
|
3464
|
-
}, /*#__PURE__*/React__default['default'].createElement(TooltipResponse, {
|
|
3465
|
-
id: id,
|
|
3466
|
-
response: buildLocalResponse(response, value)
|
|
3467
|
-
}))), /*#__PURE__*/React__default['default'].createElement("div", {
|
|
3468
|
-
className: "lunatic-input-number-errors"
|
|
3469
|
-
}, messagesError.map(function (m, i) {
|
|
3470
|
-
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
3471
|
-
key: i,
|
|
3472
|
-
className: "error"
|
|
3473
|
-
}, m);
|
|
3474
|
-
}))), /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
3475
|
-
id: id,
|
|
3476
|
-
type: DETACHABLE,
|
|
3477
|
-
declarations: declarations,
|
|
3478
|
-
features: features,
|
|
3479
|
-
bindings: bindings
|
|
3480
|
-
}));
|
|
3481
|
-
};
|
|
3482
|
-
|
|
3483
|
-
var minMaxValidator = function minMaxValidator(_ref3) {
|
|
3484
|
-
var min = _ref3.min,
|
|
3485
|
-
max = _ref3.max;
|
|
3486
|
-
return function (value) {
|
|
3487
|
-
if (!value) {
|
|
3488
|
-
return undefined;
|
|
3489
|
-
}
|
|
3490
|
-
|
|
3491
|
-
var valueNumber = Number(value);
|
|
3492
|
-
if (!min && isDef(max) && valueNumber > max) return /*#__PURE__*/React__default['default'].createElement("span", null, "La valeur doit \xEAtre inf\xE9rieure \xE0 ".concat(max));else if (isDef(min) && !max && valueNumber < min) return /*#__PURE__*/React__default['default'].createElement("span", null, "La valeur doit \xEAtre sup\xE9rieure \xE0 ".concat(min));else if (isDef(min) && isDef(max) && (valueNumber < min || valueNumber > max)) return /*#__PURE__*/React__default['default'].createElement("span", null, "La valeur doit \xEAtre comprise entre ".concat(min, " et ").concat(max));
|
|
3493
|
-
return undefined;
|
|
3494
|
-
};
|
|
3495
|
-
};
|
|
3496
|
-
|
|
3497
|
-
var isDef = function isDef(number) {
|
|
3498
|
-
return number || number === 0;
|
|
3499
|
-
};
|
|
3500
|
-
|
|
3501
|
-
InputNumber.defaultProps = {
|
|
3502
|
-
label: '',
|
|
3503
|
-
preferences: ['COLLECTED'],
|
|
3504
|
-
response: {},
|
|
3505
|
-
min: undefined,
|
|
3506
|
-
max: undefined,
|
|
3507
|
-
decimals: 0,
|
|
3508
|
-
placeholder: '',
|
|
3509
|
-
readOnly: false,
|
|
3510
|
-
disabled: false,
|
|
3511
|
-
autoComplete: false,
|
|
3512
|
-
focused: false,
|
|
3513
|
-
declarations: [],
|
|
3514
|
-
features: [],
|
|
3515
|
-
bindings: {},
|
|
3516
|
-
labelPosition: 'DEFAULT',
|
|
3517
|
-
unitPosition: 'DEFAULT',
|
|
3518
|
-
mandatory: false,
|
|
3519
|
-
management: false,
|
|
3520
|
-
style: {},
|
|
3521
|
-
validators: []
|
|
3522
|
-
};
|
|
3523
|
-
InputNumber.propTypes = {
|
|
3524
|
-
id: PropTypes__default['default'].string.isRequired,
|
|
3525
|
-
label: PropTypes__default['default'].string,
|
|
3526
|
-
preferences: PropTypes__default['default'].arrayOf(valueType),
|
|
3527
|
-
response: response,
|
|
3528
|
-
min: PropTypes__default['default'].number,
|
|
3529
|
-
max: PropTypes__default['default'].number,
|
|
3530
|
-
decimals: PropTypes__default['default'].number,
|
|
3531
|
-
placeholder: PropTypes__default['default'].string,
|
|
3532
|
-
handleChange: PropTypes__default['default'].func.isRequired,
|
|
3533
|
-
readOnly: PropTypes__default['default'].bool,
|
|
3534
|
-
disabled: PropTypes__default['default'].bool,
|
|
3535
|
-
autoComplete: PropTypes__default['default'].bool,
|
|
3536
|
-
focused: PropTypes__default['default'].bool,
|
|
3537
|
-
declarations: declarations,
|
|
3538
|
-
features: PropTypes__default['default'].arrayOf(PropTypes__default['default'].string),
|
|
3539
|
-
bindings: PropTypes__default['default'].object,
|
|
3540
|
-
labelPosition: PropTypes__default['default'].oneOf(['DEFAULT', 'TOP', 'BOTTOM', 'LEFT', 'RIGHT']),
|
|
3541
|
-
unitPosition: PropTypes__default['default'].oneOf(['DEFAULT', 'BEFORE', 'AFTER']),
|
|
3542
|
-
mandatory: PropTypes__default['default'].bool,
|
|
3543
|
-
management: PropTypes__default['default'].bool,
|
|
3544
|
-
style: PropTypes__default['default'].object,
|
|
3545
|
-
validators: PropTypes__default['default'].arrayOf(PropTypes__default['default'].func)
|
|
3546
|
-
};
|
|
3547
|
-
var inputNumber = /*#__PURE__*/React__default['default'].memo(InputNumber, areEqual);
|
|
3548
|
-
|
|
3549
|
-
var FilterDescription = function FilterDescription(_ref) {
|
|
3550
|
-
var id = _ref.id,
|
|
3551
|
-
label = _ref.label,
|
|
3552
|
-
filterDescription = _ref.filterDescription,
|
|
3553
|
-
features = _ref.features,
|
|
3554
|
-
bindings = _ref.bindings,
|
|
3555
|
-
style = _ref.style;
|
|
3556
|
-
return filterDescription ? /*#__PURE__*/React__default['default'].createElement("div", {
|
|
3557
|
-
id: "filter-description-".concat(id),
|
|
3558
|
-
"aria-label": "filter-description",
|
|
3559
|
-
className: "filter-description-lunatic",
|
|
3560
|
-
style: buildStyleObject(style)
|
|
3561
|
-
}, interpret(features)(bindings)(label)) : null;
|
|
3562
|
-
};
|
|
3563
|
-
|
|
3564
|
-
FilterDescription.defaultProps = {
|
|
3565
|
-
filterDescription: false,
|
|
3566
|
-
features: [],
|
|
3567
|
-
bindings: {},
|
|
3568
|
-
style: {}
|
|
3569
|
-
};
|
|
3570
|
-
FilterDescription.propTypes = {
|
|
3571
|
-
id: PropTypes__default['default'].string.isRequired,
|
|
3572
|
-
label: PropTypes__default['default'].string.isRequired,
|
|
3573
|
-
filterDescription: PropTypes__default['default'].bool,
|
|
3574
|
-
features: PropTypes__default['default'].arrayOf(PropTypes__default['default'].string),
|
|
3575
|
-
bindings: PropTypes__default['default'].object,
|
|
3576
|
-
style: PropTypes__default['default'].object
|
|
3577
|
-
};
|
|
3578
|
-
|
|
3579
|
-
var css_248z$8 = "* {\n box-sizing: border-box;\n}\n\n.mandatory:after {\n content: \" *\";\n color: red;\n}\n\n.horizontal-options {\n display: inline-block;\n margin-right: 2em;\n}\n\nlabel,\n.lunatic-dropdown-label {\n margin-bottom: 0.5em;\n}\n\n.label-top {\n display: flex;\n flex-direction: column;\n}\n\n.label-bottom {\n display: flex;\n flex-direction: column-reverse;\n}\n\n.label-right {\n justify-content: flex-end;\n display: flex;\n flex-direction: row-reverse;\n align-items: baseline;\n}\n.label-right :first-child {\n margin-right: 1rem;\n}\n\n.label-left {\n display: flex;\n flex-direction: row;\n align-items: baseline;\n}\n.label-left :first-child {\n margin-right: 1rem;\n}\n\n.field-container {\n display: flex;\n}\n\n.tooltip {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n.field-with-tooltip {\n width: calc(100% - 25px);\n position: relative;\n}\n\n.field {\n width: 100%;\n position: relative;\n}\n\n.progress-lunatic {\n height: 30px;\n position: relative;\n background: #d3d3d3;\n -moz-border-radius: 20px;\n -webkit-border-radius: 20px;\n border-radius: 20px;\n padding: 5px;\n box-shadow: inset 0 -1px 1px rgba(255, 255, 255, 0.3);\n text-align: center;\n font-weight: bold;\n}\n\n.progress-lunatic > span {\n display: block;\n height: 100%;\n border-radius: 20px;\n background-color: #e80a4d;\n opacity: 0.6;\n box-shadow: inset 0 2px 9px rgba(255, 255, 255, 0.3), inset 0 -2px 6px rgba(0, 0, 0, 0.4);\n position: relative;\n top: -18px;\n overflow: hidden;\n}\n\n.progress-lunatic > span:after {\n content: \"\";\n position: absolute;\n top: 0;\n left: 0;\n bottom: 0;\n right: 0;\n background-image: linear-gradient(-45deg, rgba(255, 255, 255, 0.2) 25%, transparent 25%, transparent 50%, rgba(255, 255, 255, 0.2) 50%, rgba(255, 255, 255, 0.2) 75%, transparent 75%, transparent);\n z-index: 1;\n background-size: 50px 50px;\n animation: move 2s linear infinite;\n border-top-right-radius: 8px;\n border-bottom-right-radius: 8px;\n border-top-left-radius: 20px;\n border-bottom-left-radius: 20px;\n overflow: hidden;\n}";
|
|
3580
|
-
styleInject(css_248z$8);
|
|
3581
|
-
|
|
3582
|
-
var ProgressBar = function ProgressBar(_ref) {
|
|
3583
|
-
var id = _ref.id,
|
|
3584
|
-
value = _ref.value,
|
|
3585
|
-
style = _ref.style;
|
|
3586
|
-
var controledValue = value;
|
|
3587
|
-
if (value < 0) controledValue = 0;
|
|
3588
|
-
if (value > 100) controledValue = 100;
|
|
3589
|
-
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
3590
|
-
id: "progress-".concat(id),
|
|
3591
|
-
className: "progress-lunatic",
|
|
3592
|
-
style: buildStyleObject(style)
|
|
3593
|
-
}, "".concat(controledValue.toFixed(0), " %"), /*#__PURE__*/React__default['default'].createElement("span", {
|
|
3594
|
-
style: {
|
|
3595
|
-
width: "".concat(controledValue, "%")
|
|
3596
|
-
}
|
|
3597
|
-
}));
|
|
3598
|
-
};
|
|
3599
|
-
|
|
3600
|
-
ProgressBar.propTypes = {
|
|
3601
|
-
id: PropTypes__default['default'].string.isRequired,
|
|
3602
|
-
value: PropTypes__default['default'].number.isRequired,
|
|
3603
|
-
style: PropTypes__default['default'].object
|
|
3604
|
-
};
|
|
3605
|
-
|
|
3606
|
-
var css_248z$9 = "* {\n box-sizing: border-box;\n}\n\n.mandatory:after {\n content: \" *\";\n color: red;\n}\n\n.horizontal-options {\n display: inline-block;\n margin-right: 2em;\n}\n\nlabel,\n.lunatic-dropdown-label {\n margin-bottom: 0.5em;\n}\n\n.label-top {\n display: flex;\n flex-direction: column;\n}\n\n.label-bottom {\n display: flex;\n flex-direction: column-reverse;\n}\n\n.label-right {\n justify-content: flex-end;\n display: flex;\n flex-direction: row-reverse;\n align-items: baseline;\n}\n.label-right :first-child {\n margin-right: 1rem;\n}\n\n.label-left {\n display: flex;\n flex-direction: row;\n align-items: baseline;\n}\n.label-left :first-child {\n margin-right: 1rem;\n}\n\n.field-container {\n display: flex;\n}\n\n.tooltip {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n.field-with-tooltip {\n width: calc(100% - 25px);\n position: relative;\n}\n\n.field {\n width: 100%;\n position: relative;\n}\n\n.radio-group {\n border: 0.1em solid #e80a4d;\n}\n\n.radio-lunatic {\n margin: 0;\n margin-right: 1em;\n margin-left: 1em;\n margin-top: 0.5em;\n}\n.radio-lunatic:focus {\n outline: none;\n box-shadow: 0 0 0.3em 0.3em #e80a4d;\n}\n.radio-lunatic:checked + label {\n border: 0.1em solid #e80a4d;\n padding: 0.3em;\n}\n\n.radio-modality {\n margin-top: 1em;\n}";
|
|
3607
|
-
styleInject(css_248z$9);
|
|
3608
|
-
|
|
3609
|
-
var Radio = function Radio(props) {
|
|
3610
|
-
return /*#__PURE__*/React__default['default'].createElement(ListDeclarationsWrapper, _extends({
|
|
3611
|
-
type: "radio"
|
|
3612
|
-
}, props));
|
|
3613
|
-
};
|
|
3614
|
-
|
|
3615
|
-
var component$2 = /*#__PURE__*/React__default['default'].memo(Radio, areEqual);
|
|
3616
|
-
|
|
3617
|
-
var buildLoopComponents = function buildLoopComponents(iterations) {
|
|
3618
|
-
return function (components) {
|
|
3619
|
-
var toFlat = _toConsumableArray(Array(iterations).keys()).map(function (rowNumber) {
|
|
3620
|
-
return buildFlatten(rowNumber)(components).map(function (c) {
|
|
3621
|
-
return _objectSpread2(_objectSpread2({}, c), {}, {
|
|
3622
|
-
rowNumber: rowNumber
|
|
3623
|
-
});
|
|
3624
|
-
});
|
|
3625
|
-
});
|
|
3626
|
-
|
|
3627
|
-
return toFlat.flat();
|
|
3628
|
-
};
|
|
3629
|
-
};
|
|
3630
|
-
|
|
3631
|
-
var buildFlatten = function buildFlatten(i) {
|
|
3632
|
-
return function (parentComponents) {
|
|
3633
|
-
return parentComponents.map(function (component) {
|
|
3634
|
-
var response = component.response,
|
|
3635
|
-
responses = component.responses,
|
|
3636
|
-
components = component.components;
|
|
3637
|
-
if (response) return buildFlattenResponse(i)(component);else if (responses) return _objectSpread2(_objectSpread2({}, component), {}, {
|
|
3638
|
-
responses: responses.map(function (r) {
|
|
3639
|
-
return buildFlattenResponse(i)(r);
|
|
3640
|
-
})
|
|
3641
|
-
});else if (components) return _objectSpread2(_objectSpread2({}, component), {}, {
|
|
3642
|
-
components: buildFlatten(i)(components)
|
|
3643
|
-
});else return component;
|
|
3644
|
-
});
|
|
3645
|
-
};
|
|
3646
|
-
};
|
|
3647
|
-
|
|
3648
|
-
var buildFlattenResponse = function buildFlattenResponse(i) {
|
|
3649
|
-
return function (component) {
|
|
3650
|
-
var response = component.response,
|
|
3651
|
-
other = _objectWithoutProperties(component, ["response"]);
|
|
3652
|
-
|
|
3653
|
-
var name = response.name,
|
|
3654
|
-
values = response.values;
|
|
3655
|
-
var newValues = Object.entries(values).reduce(function (acc, _ref) {
|
|
3656
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
3657
|
-
key = _ref2[0],
|
|
3658
|
-
value = _ref2[1];
|
|
3659
|
-
|
|
3660
|
-
return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, key, value ? value[i] : null));
|
|
3661
|
-
}, {});
|
|
3662
|
-
return _objectSpread2(_objectSpread2({}, other), {}, {
|
|
3663
|
-
response: {
|
|
3664
|
-
name: name,
|
|
3665
|
-
values: newValues
|
|
3666
|
-
}
|
|
3667
|
-
});
|
|
3668
|
-
};
|
|
3669
|
-
};
|
|
3670
|
-
|
|
3671
|
-
var css_248z$a = "* {\n box-sizing: border-box;\n}\n\n.mandatory:after {\n content: \" *\";\n color: red;\n}\n\n.horizontal-options {\n display: inline-block;\n margin-right: 2em;\n}\n\nlabel,\n.lunatic-dropdown-label {\n margin-bottom: 0.5em;\n}\n\n.label-top {\n display: flex;\n flex-direction: column;\n}\n\n.label-bottom {\n display: flex;\n flex-direction: column-reverse;\n}\n\n.label-right {\n justify-content: flex-end;\n display: flex;\n flex-direction: row-reverse;\n align-items: baseline;\n}\n.label-right :first-child {\n margin-right: 1rem;\n}\n\n.label-left {\n display: flex;\n flex-direction: row;\n align-items: baseline;\n}\n.label-left :first-child {\n margin-right: 1rem;\n}\n\n.field-container {\n display: flex;\n}\n\n.tooltip {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n.field-with-tooltip {\n width: calc(100% - 25px);\n position: relative;\n}\n\n.field {\n width: 100%;\n position: relative;\n}\n\n.lunatic-loop {\n margin-top: 1em;\n margin-bottom: 1em;\n border: solid 2px #e80a4d;\n padding: 2em;\n}\n.lunatic-loop .loop-label {\n text-align: center;\n font-weight: bold;\n font-size: 2em;\n}\n.lunatic-loop .loop-component {\n margin-top: 0.4em;\n margin-bottom: 0.4em;\n}";
|
|
3672
|
-
styleInject(css_248z$a);
|
|
3673
|
-
|
|
3674
|
-
var Loop = function Loop(_ref) {
|
|
3675
|
-
var id = _ref.id;
|
|
3676
|
-
_ref.label;
|
|
3677
|
-
var iterations = _ref.iterations,
|
|
3678
|
-
components = _ref.components,
|
|
3679
|
-
bindings = _ref.bindings,
|
|
3680
|
-
handleChange = _ref.handleChange,
|
|
3681
|
-
loopDependencies = _ref.loopDependencies,
|
|
3682
|
-
orchetratorProps = _objectWithoutProperties(_ref, ["id", "label", "iterations", "components", "bindings", "handleChange", "loopDependencies"]);
|
|
3683
|
-
|
|
3684
|
-
var _useState = React.useState({}),
|
|
3685
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
3686
|
-
todo = _useState2[0],
|
|
3687
|
-
setTodo = _useState2[1];
|
|
3688
|
-
|
|
3689
|
-
var vectorialBindings = buildVectorialBindings(bindings);
|
|
3690
|
-
var features = orchetratorProps.features;
|
|
3691
|
-
var iterationNb = interpret(features)(vectorialBindings)(iterations);
|
|
3692
|
-
var involvedVariables = getInvolvedVariables(components);
|
|
3693
|
-
/**
|
|
3694
|
-
* Handle the increase in the number of iterations
|
|
3695
|
-
* Assume we only want to update if iterationNb changes
|
|
3696
|
-
*/
|
|
3697
|
-
|
|
3698
|
-
React.useEffect(function () {
|
|
3699
|
-
var toUpdate = involvedVariables.reduce(function (acc, _ref2) {
|
|
3700
|
-
var iv = _ref2.name,
|
|
3701
|
-
depth = _ref2.depth;
|
|
3702
|
-
if (bindings[iv] && iterationNb > bindings[iv].length) return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, iv, [].concat(_toConsumableArray(bindings[iv]), _toConsumableArray(new Array(iterationNb - bindings[iv].length).fill(buildEmptyValue(depth))))));
|
|
3703
|
-
return acc;
|
|
3704
|
-
}, {});
|
|
3705
|
-
if (Object.keys(toUpdate).length !== 0) handleChange(toUpdate); // eslint-disable-next-line react-hooks/exhaustive-deps
|
|
3706
|
-
}, [iterationNb]);
|
|
3707
|
-
React.useEffect(function () {
|
|
3708
|
-
if (Object.keys(todo).length !== 0) {
|
|
3709
|
-
var up = todo.up,
|
|
3710
|
-
rowNumber = todo.rowNumber;
|
|
3711
|
-
|
|
3712
|
-
var _Object$entries$ = _slicedToArray(Object.entries(up)[0], 2),
|
|
3713
|
-
key = _Object$entries$[0],
|
|
3714
|
-
value = _Object$entries$[1];
|
|
3715
|
-
|
|
3716
|
-
var previousValue = bindings[key];
|
|
3717
|
-
var newValue = previousValue.map(function (v, i) {
|
|
3718
|
-
return i === rowNumber ? value : v;
|
|
3719
|
-
});
|
|
3720
|
-
handleChange(_defineProperty({}, key, newValue));
|
|
3721
|
-
setTodo({});
|
|
18
|
+
Object.keys(_components).forEach(function (key) {
|
|
19
|
+
if (key === "default" || key === "__esModule") return;
|
|
20
|
+
if (Object.prototype.hasOwnProperty.call(_exportNames, key)) return;
|
|
21
|
+
if (key in exports && exports[key] === _components[key]) return;
|
|
22
|
+
Object.defineProperty(exports, key, {
|
|
23
|
+
enumerable: true,
|
|
24
|
+
get: function get() {
|
|
25
|
+
return _components[key];
|
|
3722
26
|
}
|
|
3723
|
-
}, [bindings, todo, handleChange]);
|
|
3724
|
-
var flattenComponents = buildLoopComponents(iterationNb)(components);
|
|
3725
|
-
if (!displayLoop(loopDependencies)(bindings)) return null;
|
|
3726
|
-
var loopComponents = flattenComponents.map(function (_ref3) {
|
|
3727
|
-
var componentType = _ref3.componentType,
|
|
3728
|
-
idC = _ref3.id,
|
|
3729
|
-
rowNumber = _ref3.rowNumber,
|
|
3730
|
-
conditionFilter = _ref3.conditionFilter,
|
|
3731
|
-
rest = _objectWithoutProperties(_ref3, ["componentType", "id", "rowNumber", "conditionFilter"]);
|
|
3732
|
-
|
|
3733
|
-
var loopBindings = buildBindingsForDeeperComponents(rowNumber)(bindings);
|
|
3734
|
-
if (!displayLoopQuestion(loopDependencies)(loopBindings)) return null;
|
|
3735
|
-
var Component = lunatic[componentType];
|
|
3736
|
-
if (interpret(features)(loopBindings, true)(conditionFilter) !== 'normal') return null;
|
|
3737
|
-
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
3738
|
-
key: "".concat(idC, "-loop-").concat(rowNumber),
|
|
3739
|
-
className: "loop-component"
|
|
3740
|
-
}, /*#__PURE__*/React__default['default'].createElement(Component, _extends({}, orchetratorProps, rest, {
|
|
3741
|
-
id: "".concat(idC, "-loop-").concat(rowNumber),
|
|
3742
|
-
handleChange: function handleChange(up) {
|
|
3743
|
-
return setTodo({
|
|
3744
|
-
up: up,
|
|
3745
|
-
rowNumber: rowNumber
|
|
3746
|
-
});
|
|
3747
|
-
},
|
|
3748
|
-
bindings: loopBindings,
|
|
3749
|
-
componentType: componentType
|
|
3750
|
-
})));
|
|
3751
|
-
});
|
|
3752
|
-
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
3753
|
-
id: "loop-".concat(id),
|
|
3754
|
-
className: "lunatic-loop"
|
|
3755
|
-
}, loopComponents);
|
|
3756
|
-
};
|
|
3757
|
-
|
|
3758
|
-
var Loop$1 = /*#__PURE__*/React__default['default'].memo(Loop, areEqual);
|
|
3759
|
-
|
|
3760
|
-
var buildContentForLoopConstructor = function buildContentForLoopConstructor(_ref) {
|
|
3761
|
-
var components = _ref.components,
|
|
3762
|
-
headers = _ref.headers;
|
|
3763
|
-
// Start hack to find interation number
|
|
3764
|
-
// Refactor if we have to handle complex components (vector, matrix)
|
|
3765
|
-
var iterations = components.find(function (c) {
|
|
3766
|
-
return c.response;
|
|
3767
|
-
}).response.values[COLLECTED].length || 1; // End
|
|
3768
|
-
|
|
3769
|
-
var initialArray = _toConsumableArray(Array(iterations).keys());
|
|
3770
|
-
|
|
3771
|
-
var uiComponents = components.map(function (comp) {
|
|
3772
|
-
var response = comp.response,
|
|
3773
|
-
other = _objectWithoutProperties(comp, ["response"]);
|
|
3774
|
-
|
|
3775
|
-
if (!response) return initialArray.map(function () {
|
|
3776
|
-
return comp;
|
|
3777
|
-
}); // Handle reponses & cells components ?
|
|
3778
|
-
|
|
3779
|
-
var name = response.name,
|
|
3780
|
-
values = response.values;
|
|
3781
|
-
return initialArray.map(function (rowNumber) {
|
|
3782
|
-
var newValues = Object.entries(values).reduce(function (acc, _ref2) {
|
|
3783
|
-
var _ref3 = _slicedToArray(_ref2, 2),
|
|
3784
|
-
key = _ref3[0],
|
|
3785
|
-
value = _ref3[1];
|
|
3786
|
-
|
|
3787
|
-
return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, key, value ? value[rowNumber] : null));
|
|
3788
|
-
}, {});
|
|
3789
|
-
return _objectSpread2(_objectSpread2({}, other), {}, {
|
|
3790
|
-
response: {
|
|
3791
|
-
name: name,
|
|
3792
|
-
values: newValues
|
|
3793
|
-
},
|
|
3794
|
-
rowNumber: rowNumber
|
|
3795
|
-
});
|
|
3796
|
-
});
|
|
3797
|
-
}, []);
|
|
3798
|
-
|
|
3799
|
-
var transpose = function transpose(m) {
|
|
3800
|
-
return m[0].map(function (_, i) {
|
|
3801
|
-
return m.map(function (x) {
|
|
3802
|
-
return x[i];
|
|
3803
|
-
});
|
|
3804
|
-
});
|
|
3805
|
-
};
|
|
3806
|
-
|
|
3807
|
-
var rows = transpose(uiComponents);
|
|
3808
|
-
return headers ? [headers].concat(_toConsumableArray(rows)) : rows;
|
|
3809
|
-
};
|
|
3810
|
-
|
|
3811
|
-
var BodyComponent = function BodyComponent(_ref) {
|
|
3812
|
-
var componentType = _ref.componentType,
|
|
3813
|
-
mainId = _ref.mainId,
|
|
3814
|
-
headers = _ref.headers,
|
|
3815
|
-
components = _ref.components,
|
|
3816
|
-
bindings = _ref.bindings,
|
|
3817
|
-
width = _ref.width,
|
|
3818
|
-
preferences = _ref.preferences,
|
|
3819
|
-
positioning = _ref.positioning,
|
|
3820
|
-
management = _ref.management,
|
|
3821
|
-
features = _ref.features,
|
|
3822
|
-
setTodo = _ref.setTodo;
|
|
3823
|
-
var uiComponents = buildContentForLoopConstructor({
|
|
3824
|
-
components: components,
|
|
3825
|
-
headers: headers
|
|
3826
27
|
});
|
|
3827
|
-
|
|
3828
|
-
id: "table-".concat(mainId),
|
|
3829
|
-
className: "table-lunatic"
|
|
3830
|
-
}, /*#__PURE__*/React__default['default'].createElement("tbody", null, uiComponents.map(function (row, i) {
|
|
3831
|
-
return /*#__PURE__*/React__default['default'].createElement("tr", {
|
|
3832
|
-
key: "table-".concat(mainId, "-row").concat(i)
|
|
3833
|
-
}, row.map(function (component, j) {
|
|
3834
|
-
var label = component.label,
|
|
3835
|
-
headerCell = component.headerCell,
|
|
3836
|
-
colspan = component.colspan,
|
|
3837
|
-
rowspan = component.rowspan,
|
|
3838
|
-
componentType = component.componentType,
|
|
3839
|
-
id = component.id,
|
|
3840
|
-
rowNumber = component.rowNumber,
|
|
3841
|
-
componentProps = _objectWithoutProperties(component, ["label", "headerCell", "colspan", "rowspan", "componentType", "id", "rowNumber"]);
|
|
3842
|
-
|
|
3843
|
-
var localBindings = buildBindingsForDeeperComponents(rowNumber)(bindings);
|
|
3844
|
-
|
|
3845
|
-
if (componentType) {
|
|
3846
|
-
var Component = lunatic[componentType];
|
|
3847
|
-
return /*#__PURE__*/React__default['default'].createElement("td", {
|
|
3848
|
-
key: "table-".concat(mainId, "-row-").concat(i, "-cell-").concat(j),
|
|
3849
|
-
style: {
|
|
3850
|
-
width: width
|
|
3851
|
-
}
|
|
3852
|
-
}, /*#__PURE__*/React__default['default'].createElement(Component, _extends({}, componentProps, {
|
|
3853
|
-
id: "".concat(id, "-row-").concat(i),
|
|
3854
|
-
label: label,
|
|
3855
|
-
handleChange: function handleChange(up) {
|
|
3856
|
-
setTodo({
|
|
3857
|
-
up: up,
|
|
3858
|
-
rowNumber: rowNumber
|
|
3859
|
-
});
|
|
3860
|
-
},
|
|
3861
|
-
preferences: preferences,
|
|
3862
|
-
positioning: positioning,
|
|
3863
|
-
management: management,
|
|
3864
|
-
features: features,
|
|
3865
|
-
bindings: localBindings,
|
|
3866
|
-
zIndex: uiComponents.length - i || 0
|
|
3867
|
-
})));
|
|
3868
|
-
}
|
|
3869
|
-
|
|
3870
|
-
var cellOptions = {
|
|
3871
|
-
key: "table-".concat(mainId, "-row-").concat(i, "-cell-").concat(j),
|
|
3872
|
-
style: {
|
|
3873
|
-
width: width
|
|
3874
|
-
},
|
|
3875
|
-
colSpan: colspan || 1,
|
|
3876
|
-
rowSpan: rowspan || 1
|
|
3877
|
-
};
|
|
3878
|
-
var interpretedLabel = interpret(features)(bindings)(label);
|
|
3879
|
-
return headerCell ? /*#__PURE__*/React__default['default'].createElement("th", cellOptions, interpretedLabel) : /*#__PURE__*/React__default['default'].createElement("td", cellOptions, interpretedLabel);
|
|
3880
|
-
}));
|
|
3881
|
-
})));else return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
3882
|
-
className: "block-for-loop"
|
|
3883
|
-
}, uiComponents.map(function (row, i) {
|
|
3884
|
-
return row.map(function (_ref2) {
|
|
3885
|
-
var componentType = _ref2.componentType,
|
|
3886
|
-
id = _ref2.id,
|
|
3887
|
-
label = _ref2.label,
|
|
3888
|
-
componentProps = _objectWithoutProperties(_ref2, ["componentType", "id", "label"]);
|
|
3889
|
-
|
|
3890
|
-
var Component = lunatic[componentType];
|
|
3891
|
-
var localBindings = buildBindingsForDeeperComponents(i)(bindings);
|
|
3892
|
-
return /*#__PURE__*/React__default['default'].createElement("div", {
|
|
3893
|
-
className: "block-component",
|
|
3894
|
-
key: "".concat(id, "-row-").concat(i)
|
|
3895
|
-
}, /*#__PURE__*/React__default['default'].createElement(Component, _extends({}, componentProps, {
|
|
3896
|
-
id: "".concat(id, "-row-").concat(i),
|
|
3897
|
-
label: label,
|
|
3898
|
-
handleChange: function handleChange(up) {
|
|
3899
|
-
setTodo({
|
|
3900
|
-
up: up,
|
|
3901
|
-
rowNumber: i
|
|
3902
|
-
});
|
|
3903
|
-
},
|
|
3904
|
-
preferences: preferences,
|
|
3905
|
-
positioning: positioning,
|
|
3906
|
-
management: management,
|
|
3907
|
-
features: features,
|
|
3908
|
-
bindings: localBindings
|
|
3909
|
-
})));
|
|
3910
|
-
});
|
|
3911
|
-
}));
|
|
3912
|
-
};
|
|
3913
|
-
|
|
3914
|
-
var LoopConstructorWrapper = function LoopConstructorWrapper(_ref) {
|
|
3915
|
-
var mainId = _ref.id,
|
|
3916
|
-
mainLabel = _ref.label,
|
|
3917
|
-
components = _ref.components,
|
|
3918
|
-
handleChange = _ref.handleChange,
|
|
3919
|
-
lines = _ref.lines,
|
|
3920
|
-
declarations = _ref.declarations,
|
|
3921
|
-
features = _ref.features,
|
|
3922
|
-
bindings = _ref.bindings,
|
|
3923
|
-
addBtnLabel = _ref.addBtnLabel,
|
|
3924
|
-
hideBtn = _ref.hideBtn,
|
|
3925
|
-
componentType = _ref.componentType,
|
|
3926
|
-
otherProps = _objectWithoutProperties(_ref, ["id", "label", "components", "handleChange", "lines", "declarations", "features", "bindings", "addBtnLabel", "hideBtn", "componentType"]);
|
|
3927
|
-
|
|
3928
|
-
var _useState = React.useState({}),
|
|
3929
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
3930
|
-
todo = _useState2[0],
|
|
3931
|
-
setTodo = _useState2[1];
|
|
3932
|
-
|
|
3933
|
-
var minLines = Math.max(lines.min || 0, getLoopConstructorInitLines(components));
|
|
3934
|
-
var maxLines = lines ? lines.max : undefined;
|
|
3935
|
-
var width = "".concat(100 / Math.max.apply(Math, _toConsumableArray(components.map(function (row) {
|
|
3936
|
-
return row.length;
|
|
3937
|
-
}))), "%");
|
|
3938
|
-
var Button$1 = Button;
|
|
3939
|
-
var involvedVariables = getInvolvedVariables(components);
|
|
3940
|
-
React.useEffect(function () {
|
|
3941
|
-
if (Object.keys(todo).length !== 0) {
|
|
3942
|
-
var up = todo.up,
|
|
3943
|
-
rowNumber = todo.rowNumber;
|
|
3944
|
-
|
|
3945
|
-
var _Object$entries$ = _slicedToArray(Object.entries(up)[0], 2),
|
|
3946
|
-
key = _Object$entries$[0],
|
|
3947
|
-
value = _Object$entries$[1];
|
|
3948
|
-
|
|
3949
|
-
var previousValue = bindings[key];
|
|
3950
|
-
var newValue = previousValue.map(function (v, i) {
|
|
3951
|
-
return i === rowNumber ? value : v;
|
|
3952
|
-
});
|
|
3953
|
-
handleChange(_defineProperty({}, key, newValue));
|
|
3954
|
-
setTodo({});
|
|
3955
|
-
}
|
|
3956
|
-
}, [bindings, todo, handleChange]);
|
|
3957
|
-
|
|
3958
|
-
var addLine = function addLine() {
|
|
3959
|
-
var toHandle = involvedVariables.reduce(function (acc, _ref2) {
|
|
3960
|
-
var iv = _ref2.name,
|
|
3961
|
-
depth = _ref2.depth;
|
|
3962
|
-
return _objectSpread2(_objectSpread2({}, acc), {}, _defineProperty({}, iv, [].concat(_toConsumableArray(bindings[iv]), [buildEmptyValue(depth)])));
|
|
3963
|
-
}, {});
|
|
3964
|
-
handleChange(toHandle);
|
|
3965
|
-
};
|
|
3966
|
-
|
|
3967
|
-
var customBtnLabel = componentType === 'Loop' && interpret(features)(bindings)(mainLabel) || addBtnLabel;
|
|
3968
|
-
return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
3969
|
-
id: mainId,
|
|
3970
|
-
type: BEFORE_QUESTION_TEXT,
|
|
3971
|
-
declarations: declarations,
|
|
3972
|
-
features: features,
|
|
3973
|
-
bindings: bindings
|
|
3974
|
-
}), componentType === 'RosterForLoop' && mainLabel && /*#__PURE__*/React__default['default'].createElement("label", {
|
|
3975
|
-
htmlFor: "loops-constructor-".concat(mainId),
|
|
3976
|
-
id: "loops-constructor-label-".concat(mainId)
|
|
3977
|
-
}, interpret(features)(bindings)(mainLabel)), /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
3978
|
-
id: mainId,
|
|
3979
|
-
type: AFTER_QUESTION_TEXT,
|
|
3980
|
-
declarations: declarations,
|
|
3981
|
-
features: features,
|
|
3982
|
-
bindings: bindings
|
|
3983
|
-
}), /*#__PURE__*/React__default['default'].createElement(BodyComponent, _extends({
|
|
3984
|
-
mainId: mainId,
|
|
3985
|
-
componentType: componentType,
|
|
3986
|
-
components: components,
|
|
3987
|
-
bindings: bindings,
|
|
3988
|
-
width: width,
|
|
3989
|
-
features: features,
|
|
3990
|
-
setTodo: setTodo
|
|
3991
|
-
}, otherProps)), !hideBtn && /*#__PURE__*/React__default['default'].createElement(Button$1, {
|
|
3992
|
-
label: "addLine",
|
|
3993
|
-
value: customBtnLabel,
|
|
3994
|
-
disabled: Number.isInteger(minLines) && minLines === maxLines || lastLoopChildLineIsEmpty(bindings)(involvedVariables),
|
|
3995
|
-
onClick: addLine
|
|
3996
|
-
}), /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
3997
|
-
id: mainId,
|
|
3998
|
-
type: DETACHABLE,
|
|
3999
|
-
declarations: declarations,
|
|
4000
|
-
features: features,
|
|
4001
|
-
bindings: bindings
|
|
4002
|
-
}));
|
|
4003
|
-
};
|
|
4004
|
-
|
|
4005
|
-
LoopConstructorWrapper.defaultProps = {
|
|
4006
|
-
label: '',
|
|
4007
|
-
preferences: ['COLLECTED'],
|
|
4008
|
-
components: [],
|
|
4009
|
-
lines: {},
|
|
4010
|
-
positioning: 'DEFAULT',
|
|
4011
|
-
declarations: [],
|
|
4012
|
-
features: [],
|
|
4013
|
-
bindings: {},
|
|
4014
|
-
addBtnLabel: 'Add a line',
|
|
4015
|
-
management: false,
|
|
4016
|
-
hideBtn: false,
|
|
4017
|
-
style: {}
|
|
4018
|
-
};
|
|
4019
|
-
LoopConstructorWrapper.propTypes = {
|
|
4020
|
-
componentType: PropTypes__default['default'].string.isRequired,
|
|
4021
|
-
id: PropTypes__default['default'].string.isRequired,
|
|
4022
|
-
label: PropTypes__default['default'].string,
|
|
4023
|
-
preferences: PropTypes__default['default'].arrayOf(valueType),
|
|
4024
|
-
components: PropTypes__default['default'].array,
|
|
4025
|
-
handleChange: PropTypes__default['default'].func.isRequired,
|
|
4026
|
-
lines: lines,
|
|
4027
|
-
positioning: PropTypes__default['default'].oneOf(['DEFAULT', 'HORIZONTAL', 'VERTICAL']),
|
|
4028
|
-
declarations: declarations,
|
|
4029
|
-
features: PropTypes__default['default'].arrayOf(PropTypes__default['default'].string),
|
|
4030
|
-
bindings: PropTypes__default['default'].object,
|
|
4031
|
-
addBtnLabel: PropTypes__default['default'].string,
|
|
4032
|
-
hideBtn: PropTypes__default['default'].bool,
|
|
4033
|
-
management: PropTypes__default['default'].bool,
|
|
4034
|
-
style: PropTypes__default['default'].object
|
|
4035
|
-
};
|
|
4036
|
-
var LoopConstructorWrapper$1 = /*#__PURE__*/React__default['default'].memo(LoopConstructorWrapper, areEqual);
|
|
4037
|
-
|
|
4038
|
-
var css_248z$b = "* {\n box-sizing: border-box;\n}\n\n.mandatory:after {\n content: \" *\";\n color: red;\n}\n\n.horizontal-options {\n display: inline-block;\n margin-right: 2em;\n}\n\nlabel,\n.lunatic-dropdown-label {\n margin-bottom: 0.5em;\n}\n\n.label-top {\n display: flex;\n flex-direction: column;\n}\n\n.label-bottom {\n display: flex;\n flex-direction: column-reverse;\n}\n\n.label-right {\n justify-content: flex-end;\n display: flex;\n flex-direction: row-reverse;\n align-items: baseline;\n}\n.label-right :first-child {\n margin-right: 1rem;\n}\n\n.label-left {\n display: flex;\n flex-direction: row;\n align-items: baseline;\n}\n.label-left :first-child {\n margin-right: 1rem;\n}\n\n.field-container {\n display: flex;\n}\n\n.tooltip {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n.field-with-tooltip {\n width: calc(100% - 25px);\n position: relative;\n}\n\n.field {\n width: 100%;\n position: relative;\n}\n\n.block-for-loop {\n margin-top: 1em;\n margin-bottom: 1em;\n}\n.block-for-loop .block-component {\n margin-top: 0.4em;\n margin-bottom: 0.4em;\n}";
|
|
4039
|
-
styleInject(css_248z$b);
|
|
4040
|
-
|
|
4041
|
-
var BlockForLoop = function BlockForLoop(props) {
|
|
4042
|
-
return /*#__PURE__*/React__default['default'].createElement(LoopConstructorWrapper$1, props);
|
|
4043
|
-
};
|
|
4044
|
-
|
|
4045
|
-
var BlockForLoop$1 = /*#__PURE__*/React__default['default'].memo(BlockForLoop, areEqual);
|
|
4046
|
-
|
|
4047
|
-
var LoopWrapper = function LoopWrapper(props) {
|
|
4048
|
-
var iterations = props.iterations;
|
|
4049
|
-
if (iterations) return /*#__PURE__*/React__default['default'].createElement(Loop$1, props);
|
|
4050
|
-
return /*#__PURE__*/React__default['default'].createElement(BlockForLoop$1, props);
|
|
4051
|
-
};
|
|
4052
|
-
|
|
4053
|
-
var RosterForLoop = function RosterForLoop(props) {
|
|
4054
|
-
return /*#__PURE__*/React__default['default'].createElement(LoopConstructorWrapper$1, props);
|
|
4055
|
-
};
|
|
4056
|
-
|
|
4057
|
-
var component$3 = /*#__PURE__*/React__default['default'].memo(RosterForLoop, areEqual);
|
|
4058
|
-
|
|
4059
|
-
var css_248z$c = "* {\n box-sizing: border-box;\n}\n\n.mandatory:after {\n content: \" *\";\n color: red;\n}\n\n.horizontal-options {\n display: inline-block;\n margin-right: 2em;\n}\n\nlabel,\n.lunatic-dropdown-label {\n margin-bottom: 0.5em;\n}\n\n.label-top {\n display: flex;\n flex-direction: column;\n}\n\n.label-bottom {\n display: flex;\n flex-direction: column-reverse;\n}\n\n.label-right {\n justify-content: flex-end;\n display: flex;\n flex-direction: row-reverse;\n align-items: baseline;\n}\n.label-right :first-child {\n margin-right: 1rem;\n}\n\n.label-left {\n display: flex;\n flex-direction: row;\n align-items: baseline;\n}\n.label-left :first-child {\n margin-right: 1rem;\n}\n\n.field-container {\n display: flex;\n}\n\n.tooltip {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n.field-with-tooltip {\n width: calc(100% - 25px);\n position: relative;\n}\n\n.field {\n width: 100%;\n position: relative;\n}\n\n.sequence-lunatic {\n height: 40px;\n box-sizing: border-box;\n border-radius: 0px;\n background-color: #e80a4d;\n border: 0.1em solid #e80a4d;\n color: white;\n font-weight: bold;\n font-size: 130%;\n padding-left: 10px;\n display: flex;\n align-items: center;\n}";
|
|
4060
|
-
styleInject(css_248z$c);
|
|
4061
|
-
|
|
4062
|
-
var Sequence = function Sequence(_ref) {
|
|
4063
|
-
var id = _ref.id,
|
|
4064
|
-
label = _ref.label,
|
|
4065
|
-
declarations = _ref.declarations,
|
|
4066
|
-
features = _ref.features,
|
|
4067
|
-
bindings = _ref.bindings,
|
|
4068
|
-
style = _ref.style;
|
|
4069
|
-
return /*#__PURE__*/React__default['default'].createElement(SimpleDeclarationsWrapper, {
|
|
4070
|
-
id: id,
|
|
4071
|
-
declarations: declarations,
|
|
4072
|
-
features: features,
|
|
4073
|
-
bindings: bindings
|
|
4074
|
-
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
4075
|
-
"aria-label": "sequence-".concat(id),
|
|
4076
|
-
className: "sequence-lunatic",
|
|
4077
|
-
style: buildStyleObject(style)
|
|
4078
|
-
}, interpret(features)(bindings)(label)));
|
|
4079
|
-
};
|
|
4080
|
-
|
|
4081
|
-
Sequence.defaultProps = {
|
|
4082
|
-
declarations: [],
|
|
4083
|
-
features: [],
|
|
4084
|
-
bindings: {},
|
|
4085
|
-
style: {}
|
|
4086
|
-
};
|
|
4087
|
-
Sequence.propTypes = {
|
|
4088
|
-
id: PropTypes__default['default'].string.isRequired,
|
|
4089
|
-
label: PropTypes__default['default'].string.isRequired,
|
|
4090
|
-
declarations: declarations,
|
|
4091
|
-
features: PropTypes__default['default'].arrayOf(PropTypes__default['default'].string),
|
|
4092
|
-
bindings: PropTypes__default['default'].object,
|
|
4093
|
-
style: PropTypes__default['default'].object
|
|
4094
|
-
};
|
|
4095
|
-
var component$4 = /*#__PURE__*/React__default['default'].memo(Sequence, areEqual);
|
|
4096
|
-
|
|
4097
|
-
var css_248z$d = "* {\n box-sizing: border-box;\n}\n\n.mandatory:after {\n content: \" *\";\n color: red;\n}\n\n.horizontal-options {\n display: inline-block;\n margin-right: 2em;\n}\n\nlabel,\n.lunatic-dropdown-label {\n margin-bottom: 0.5em;\n}\n\n.label-top {\n display: flex;\n flex-direction: column;\n}\n\n.label-bottom {\n display: flex;\n flex-direction: column-reverse;\n}\n\n.label-right {\n justify-content: flex-end;\n display: flex;\n flex-direction: row-reverse;\n align-items: baseline;\n}\n.label-right :first-child {\n margin-right: 1rem;\n}\n\n.label-left {\n display: flex;\n flex-direction: row;\n align-items: baseline;\n}\n.label-left :first-child {\n margin-right: 1rem;\n}\n\n.field-container {\n display: flex;\n}\n\n.tooltip {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n.field-with-tooltip {\n width: calc(100% - 25px);\n position: relative;\n}\n\n.field {\n width: 100%;\n position: relative;\n}\n\n.subsequence-lunatic {\n height: 20px;\n box-sizing: border-box;\n border-radius: 0px;\n background-color: #e80a4d;\n border: 0.1em solid #e80a4d;\n color: white;\n font-weight: bold;\n font-size: 90%;\n padding-left: 10px;\n display: flex;\n align-items: center;\n}";
|
|
4098
|
-
styleInject(css_248z$d);
|
|
4099
|
-
|
|
4100
|
-
var Subsequence = function Subsequence(_ref) {
|
|
4101
|
-
var id = _ref.id,
|
|
4102
|
-
label = _ref.label,
|
|
4103
|
-
declarations = _ref.declarations,
|
|
4104
|
-
features = _ref.features,
|
|
4105
|
-
bindings = _ref.bindings,
|
|
4106
|
-
style = _ref.style;
|
|
4107
|
-
return /*#__PURE__*/React__default['default'].createElement(SimpleDeclarationsWrapper, {
|
|
4108
|
-
id: id,
|
|
4109
|
-
declarations: declarations,
|
|
4110
|
-
features: features,
|
|
4111
|
-
bindings: bindings
|
|
4112
|
-
}, /*#__PURE__*/React__default['default'].createElement("div", {
|
|
4113
|
-
"aria-label": "subsequence-".concat(id),
|
|
4114
|
-
className: "subsequence-lunatic",
|
|
4115
|
-
style: buildStyleObject(style)
|
|
4116
|
-
}, interpret(features)(bindings)(label)));
|
|
4117
|
-
};
|
|
4118
|
-
|
|
4119
|
-
Subsequence.defaultProps = {
|
|
4120
|
-
declarations: [],
|
|
4121
|
-
features: [],
|
|
4122
|
-
bindings: {},
|
|
4123
|
-
style: {}
|
|
4124
|
-
};
|
|
4125
|
-
Subsequence.propTypes = {
|
|
4126
|
-
id: PropTypes__default['default'].string.isRequired,
|
|
4127
|
-
label: PropTypes__default['default'].string.isRequired,
|
|
4128
|
-
declarations: declarations,
|
|
4129
|
-
features: PropTypes__default['default'].arrayOf(PropTypes__default['default'].string),
|
|
4130
|
-
bindings: PropTypes__default['default'].object,
|
|
4131
|
-
style: PropTypes__default['default'].object
|
|
4132
|
-
};
|
|
4133
|
-
var component$5 = /*#__PURE__*/React__default['default'].memo(Subsequence, areEqual);
|
|
4134
|
-
|
|
4135
|
-
var css_248z$e = "* {\n box-sizing: border-box;\n}\n\n.mandatory:after {\n content: \" *\";\n color: red;\n}\n\n.horizontal-options {\n display: inline-block;\n margin-right: 2em;\n}\n\nlabel,\n.lunatic-dropdown-label {\n margin-bottom: 0.5em;\n}\n\n.label-top {\n display: flex;\n flex-direction: column;\n}\n\n.label-bottom {\n display: flex;\n flex-direction: column-reverse;\n}\n\n.label-right {\n justify-content: flex-end;\n display: flex;\n flex-direction: row-reverse;\n align-items: baseline;\n}\n.label-right :first-child {\n margin-right: 1rem;\n}\n\n.label-left {\n display: flex;\n flex-direction: row;\n align-items: baseline;\n}\n.label-left :first-child {\n margin-right: 1rem;\n}\n\n.field-container {\n display: flex;\n}\n\n.tooltip {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n.field-with-tooltip {\n width: calc(100% - 25px);\n position: relative;\n}\n\n.field {\n width: 100%;\n position: relative;\n}\n\n.textarea-lunatic {\n width: 100%;\n box-sizing: border-box;\n border: solid 2px #e80a4d;\n border-radius: 10px;\n padding: 5px;\n}\n.textarea-lunatic:focus {\n outline: none;\n box-shadow: 0 0 10px #e80a4d;\n}\n.textarea-lunatic:read-only {\n background-color: #ebebe4;\n}";
|
|
4136
|
-
styleInject(css_248z$e);
|
|
4137
|
-
|
|
4138
|
-
var Textarea = function Textarea(props) {
|
|
4139
|
-
return /*#__PURE__*/React__default['default'].createElement(InputDeclarationsWrapper, _extends({
|
|
4140
|
-
type: null,
|
|
4141
|
-
roleType: "textarea"
|
|
4142
|
-
}, props));
|
|
4143
|
-
};
|
|
4144
|
-
|
|
4145
|
-
var component$6 = /*#__PURE__*/React__default['default'].memo(Textarea, areEqual);
|
|
4146
|
-
|
|
4147
|
-
var css_248z$f = "* {\n box-sizing: border-box;\n}\n\n.mandatory:after {\n content: \" *\";\n color: red;\n}\n\n.horizontal-options {\n display: inline-block;\n margin-right: 2em;\n}\n\nlabel,\n.lunatic-dropdown-label {\n margin-bottom: 0.5em;\n}\n\n.label-top {\n display: flex;\n flex-direction: column;\n}\n\n.label-bottom {\n display: flex;\n flex-direction: column-reverse;\n}\n\n.label-right {\n justify-content: flex-end;\n display: flex;\n flex-direction: row-reverse;\n align-items: baseline;\n}\n.label-right :first-child {\n margin-right: 1rem;\n}\n\n.label-left {\n display: flex;\n flex-direction: row;\n align-items: baseline;\n}\n.label-left :first-child {\n margin-right: 1rem;\n}\n\n.field-container {\n display: flex;\n}\n\n.tooltip {\n display: flex;\n flex-direction: column;\n justify-content: center;\n align-items: center;\n}\n\n.field-with-tooltip {\n width: calc(100% - 25px);\n position: relative;\n}\n\n.field {\n width: 100%;\n position: relative;\n}\n\n.table-lunatic {\n table-layout: fixed;\n border-collapse: collapse;\n margin-top: 0.3em;\n margin-bottom: 0.3em;\n}\n.table-lunatic td,\n.table-lunatic th {\n border: 0.15em solid #e80a4d;\n padding: 0.2em;\n}\n.table-lunatic td fieldset,\n.table-lunatic th fieldset {\n margin: none;\n border: none;\n}\n.table-lunatic td fieldset .radio-modality,\n.table-lunatic th fieldset .radio-modality {\n margin-top: 0;\n}\n.table-lunatic td fieldset .checkbox-modality,\n.table-lunatic th fieldset .checkbox-modality {\n margin-top: 0;\n}";
|
|
4148
|
-
styleInject(css_248z$f);
|
|
4149
|
-
|
|
4150
|
-
var Table = function Table(_ref) {
|
|
4151
|
-
var tableId = _ref.id,
|
|
4152
|
-
tableLabel = _ref.label,
|
|
4153
|
-
preferences = _ref.preferences,
|
|
4154
|
-
cells = _ref.cells,
|
|
4155
|
-
handleChange = _ref.handleChange,
|
|
4156
|
-
initLines = _ref.lines,
|
|
4157
|
-
positioning = _ref.positioning,
|
|
4158
|
-
declarations = _ref.declarations,
|
|
4159
|
-
features = _ref.features,
|
|
4160
|
-
bindings = _ref.bindings,
|
|
4161
|
-
addBtnLabel = _ref.addBtnLabel,
|
|
4162
|
-
hideBtn = _ref.hideBtn,
|
|
4163
|
-
management = _ref.management;
|
|
4164
|
-
var minLines = initLines ? Math.max(initLines.min, getRosterInitLines(cells)) : undefined;
|
|
4165
|
-
var maxLines = initLines ? initLines.max : undefined;
|
|
4166
|
-
|
|
4167
|
-
var _useState = React.useState(minLines),
|
|
4168
|
-
_useState2 = _slicedToArray(_useState, 2),
|
|
4169
|
-
lines = _useState2[0],
|
|
4170
|
-
setLines = _useState2[1];
|
|
4171
|
-
|
|
4172
|
-
var width = "".concat(100 / Math.max.apply(Math, _toConsumableArray(cells.map(function (line) {
|
|
4173
|
-
return line.length;
|
|
4174
|
-
}))), "%");
|
|
4175
|
-
var Button$1 = Button;
|
|
4176
|
-
return /*#__PURE__*/React__default['default'].createElement(React__default['default'].Fragment, null, /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
4177
|
-
id: tableId,
|
|
4178
|
-
type: BEFORE_QUESTION_TEXT,
|
|
4179
|
-
declarations: declarations,
|
|
4180
|
-
features: features,
|
|
4181
|
-
bindings: bindings
|
|
4182
|
-
}), tableLabel && /*#__PURE__*/React__default['default'].createElement("label", {
|
|
4183
|
-
htmlFor: "table-one-axis-".concat(tableId),
|
|
4184
|
-
id: "table-one-axis-label-".concat(tableId)
|
|
4185
|
-
}, interpret(features)(bindings)(tableLabel)), /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
4186
|
-
id: tableId,
|
|
4187
|
-
type: AFTER_QUESTION_TEXT,
|
|
4188
|
-
declarations: declarations,
|
|
4189
|
-
features: features,
|
|
4190
|
-
bindings: bindings
|
|
4191
|
-
}), /*#__PURE__*/React__default['default'].createElement("table", {
|
|
4192
|
-
id: "table-".concat(tableId),
|
|
4193
|
-
className: "table-lunatic"
|
|
4194
|
-
}, /*#__PURE__*/React__default['default'].createElement("tbody", null, (minLines || minLines === 0 ? cells.slice(0, lines + 1) : cells).map(function (line, i) {
|
|
4195
|
-
return /*#__PURE__*/React__default['default'].createElement("tr", {
|
|
4196
|
-
key: "table-".concat(tableId, "-line").concat(i)
|
|
4197
|
-
}, line.map(function (component, j) {
|
|
4198
|
-
var label = component.label,
|
|
4199
|
-
headerCell = component.headerCell,
|
|
4200
|
-
colspan = component.colspan,
|
|
4201
|
-
rowspan = component.rowspan,
|
|
4202
|
-
componentType = component.componentType,
|
|
4203
|
-
componentProps = _objectWithoutProperties(component, ["label", "headerCell", "colspan", "rowspan", "componentType"]);
|
|
4204
|
-
|
|
4205
|
-
if (componentType) {
|
|
4206
|
-
var Component = lunatic[componentType];
|
|
4207
|
-
return /*#__PURE__*/React__default['default'].createElement("td", {
|
|
4208
|
-
key: "table-".concat(tableId, "-line").concat(i, "-cell-").concat(j),
|
|
4209
|
-
style: {
|
|
4210
|
-
width: width
|
|
4211
|
-
}
|
|
4212
|
-
}, /*#__PURE__*/React__default['default'].createElement(Component, _extends({
|
|
4213
|
-
label: label,
|
|
4214
|
-
handleChange: handleChange,
|
|
4215
|
-
preferences: preferences,
|
|
4216
|
-
positioning: positioning,
|
|
4217
|
-
management: management,
|
|
4218
|
-
features: features,
|
|
4219
|
-
bindings: bindings
|
|
4220
|
-
}, componentProps, {
|
|
4221
|
-
zIndex: cells.length - i || 0
|
|
4222
|
-
})));
|
|
4223
|
-
}
|
|
4224
|
-
|
|
4225
|
-
var cellOptions = {
|
|
4226
|
-
key: "table-".concat(tableId, "-line").concat(i, "-cell-").concat(j),
|
|
4227
|
-
style: {
|
|
4228
|
-
width: width
|
|
4229
|
-
},
|
|
4230
|
-
colSpan: colspan || 1,
|
|
4231
|
-
rowSpan: rowspan || 1
|
|
4232
|
-
};
|
|
4233
|
-
var interpretedLabel = interpret(features)(bindings)(label);
|
|
4234
|
-
return headerCell ? /*#__PURE__*/React__default['default'].createElement("th", cellOptions, interpretedLabel) : /*#__PURE__*/React__default['default'].createElement("td", cellOptions, interpretedLabel);
|
|
4235
|
-
}));
|
|
4236
|
-
}))), Number.isInteger(minLines) && lines < maxLines && !hideBtn && /*#__PURE__*/React__default['default'].createElement(Button$1, {
|
|
4237
|
-
label: "addLine",
|
|
4238
|
-
value: addBtnLabel,
|
|
4239
|
-
onClick: function onClick() {
|
|
4240
|
-
return setLines(lines + 1);
|
|
4241
|
-
}
|
|
4242
|
-
}), /*#__PURE__*/React__default['default'].createElement(Declarations, {
|
|
4243
|
-
id: tableId,
|
|
4244
|
-
type: DETACHABLE,
|
|
4245
|
-
declarations: declarations,
|
|
4246
|
-
features: features,
|
|
4247
|
-
bindings: bindings
|
|
4248
|
-
}));
|
|
4249
|
-
};
|
|
28
|
+
});
|
|
4250
29
|
|
|
4251
|
-
|
|
4252
|
-
label: '',
|
|
4253
|
-
preferences: ['COLLECTED'],
|
|
4254
|
-
cells: [],
|
|
4255
|
-
lines: {},
|
|
4256
|
-
positioning: 'DEFAULT',
|
|
4257
|
-
declarations: [],
|
|
4258
|
-
features: [],
|
|
4259
|
-
bindings: {},
|
|
4260
|
-
addBtnLabel: 'Add a line',
|
|
4261
|
-
management: false,
|
|
4262
|
-
hideBtn: false,
|
|
4263
|
-
style: {}
|
|
4264
|
-
};
|
|
4265
|
-
Table.propTypes = {
|
|
4266
|
-
id: PropTypes__default['default'].string.isRequired,
|
|
4267
|
-
label: PropTypes__default['default'].string,
|
|
4268
|
-
preferences: PropTypes__default['default'].arrayOf(valueType),
|
|
4269
|
-
cells: PropTypes__default['default'].array,
|
|
4270
|
-
handleChange: PropTypes__default['default'].func.isRequired,
|
|
4271
|
-
lines: lines,
|
|
4272
|
-
positioning: PropTypes__default['default'].oneOf(['DEFAULT', 'HORIZONTAL', 'VERTICAL']),
|
|
4273
|
-
declarations: declarations,
|
|
4274
|
-
features: PropTypes__default['default'].arrayOf(PropTypes__default['default'].string),
|
|
4275
|
-
bindings: PropTypes__default['default'].object,
|
|
4276
|
-
addBtnLabel: PropTypes__default['default'].string,
|
|
4277
|
-
hideBtn: PropTypes__default['default'].bool,
|
|
4278
|
-
management: PropTypes__default['default'].bool,
|
|
4279
|
-
style: PropTypes__default['default'].object
|
|
4280
|
-
};
|
|
4281
|
-
var table = /*#__PURE__*/React__default['default'].memo(Table, areEqual);
|
|
30
|
+
var _useLunatic = _interopRequireDefault(require("./use-lunatic"));
|
|
4282
31
|
|
|
4283
|
-
|
|
4284
|
-
exports.Button = Button;
|
|
4285
|
-
exports.CheckboxBoolean = boolean;
|
|
4286
|
-
exports.CheckboxGroup = group;
|
|
4287
|
-
exports.CheckboxOne = one;
|
|
4288
|
-
exports.Datepicker = component;
|
|
4289
|
-
exports.Declarations = Declarations;
|
|
4290
|
-
exports.Dropdown = component$1;
|
|
4291
|
-
exports.FilterDescription = FilterDescription;
|
|
4292
|
-
exports.Input = input;
|
|
4293
|
-
exports.InputNumber = inputNumber;
|
|
4294
|
-
exports.Loop = LoopWrapper;
|
|
4295
|
-
exports.ProgressBar = ProgressBar;
|
|
4296
|
-
exports.Radio = component$2;
|
|
4297
|
-
exports.RosterForLoop = component$3;
|
|
4298
|
-
exports.Sequence = component$4;
|
|
4299
|
-
exports.Subsequence = component$5;
|
|
4300
|
-
exports.Table = table;
|
|
4301
|
-
exports.Textarea = component$6;
|
|
4302
|
-
exports.TooltipResponse = TooltipResponse;
|
|
4303
|
-
exports.getBindings = getBindings;
|
|
4304
|
-
exports.getCollectedState = getCollectedState;
|
|
4305
|
-
exports.getCollectedStateByValueType = getCollectedStateByValueType;
|
|
4306
|
-
exports.getState = getState;
|
|
4307
|
-
exports.interpret = interpret;
|
|
4308
|
-
exports.interpretWithEmptyDefault = interpretWithEmptyDefault;
|
|
4309
|
-
exports.mergeQuestionnaireAndData = mergeQuestionnaireAndData;
|
|
4310
|
-
exports.useLunatic = useLunatic;
|
|
4311
|
-
//# sourceMappingURL=index.js.map
|
|
32
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|