@inseefr/lunatic 2.5.2-rc1-beta → 2.6.0-rc.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.fr.md +186 -0
- package/README.md +111 -94
- package/lib/components/button/lunatic-button.js +10 -13
- package/lib/components/checkbox/checkbox-group/html/checkbox-group.js +0 -1
- package/lib/components/commons/components/combo-box/combo-box-content.js +2 -1
- package/lib/components/commons/components/combo-box/combo-box.js +94 -66
- package/lib/components/commons/components/combo-box/combo-box.stories.js +69 -8
- package/lib/components/commons/components/combo-box/panel/panel.js +0 -1
- package/lib/components/commons/components/combo-box/selection/LabelOrInput.js +4 -1
- package/lib/components/commons/components/combo-box/selection/LabelOrInput.spec.js +2 -4
- package/lib/components/commons/components/combo-box/selection/combo-box-label-selection.js +5 -2
- package/lib/components/commons/components/combo-box/selection/label-selection.js +4 -2
- package/lib/components/commons/components/combo-box/selection/selection.js +2 -0
- package/lib/components/commons/components/fab/fab.js +0 -1
- package/lib/components/commons/components/fieldset.js +0 -1
- package/lib/components/commons/components/lunatic-component-with-label.js +1 -3
- package/lib/components/commons/components/md-label/md-label.js +5 -1
- package/lib/components/commons/components/md-label/md-label.spec.js +15 -0
- package/lib/components/commons/components/missing/missing.js +1 -3
- package/lib/components/commons/components/variable-status/variable-status.js +2 -3
- package/lib/components/commons/create-customizable-field.js +1 -0
- package/lib/components/commons/icons/closed-icon.js +0 -2
- package/lib/components/commons/icons/cross-icon.js +0 -2
- package/lib/components/commons/index.js +0 -7
- package/lib/components/component-set/html/__snapshots__/component-set.spec.tsx.snap +124 -0
- package/lib/components/component-set/html/{legend/legend.js → component-set-legend.js} +4 -6
- package/lib/components/component-set/html/component-set-wrapper.js +16 -0
- package/lib/components/component-set/html/component-set.js +7 -8
- package/lib/components/component-set/html/component-set.spec.js +91 -0
- package/lib/components/component-set/lunatic-component-set.js +19 -9
- package/lib/components/datepicker/html/__snapshots__/datepicker.spec.tsx.snap +34 -0
- package/lib/components/datepicker/html/datepicker-input.js +0 -1
- package/lib/components/datepicker/html/datepicker.js +1 -4
- package/lib/components/datepicker/html/datepicker.spec.js +38 -0
- package/lib/components/datepicker/lunatic-datepicker.js +0 -1
- package/lib/components/dropdown/html/__snapshots__/dropdown.spec.tsx.snap +85 -0
- package/lib/components/dropdown/html/dropdown-simple/dropdown-simple.js +3 -2
- package/lib/components/dropdown/html/dropdown-simple/simple-label-renderer.js +0 -2
- package/lib/components/dropdown/html/dropdown-writable/dropdown-writable.js +4 -5
- package/lib/components/dropdown/html/dropdown-writable/writable-label-renderer.js +1 -4
- package/lib/components/dropdown/html/dropdown-writable/writable-option-renderer.js +1 -3
- package/lib/components/dropdown/html/dropdown.js +4 -2
- package/lib/components/dropdown/html/dropdown.spec.js +48 -0
- package/lib/components/dropdown/lunatic-dropdown.js +5 -4
- package/lib/components/duration/getDurationFromValue.js +0 -1
- package/lib/components/filter-description/component.js +0 -2
- package/lib/components/index.js +6 -5
- package/lib/components/input/html/__snapshots__/input.spec.tsx.snap +34 -0
- package/lib/components/input/html/input.js +4 -5
- package/lib/components/input/html/input.spec.js +81 -0
- package/lib/components/input/lunatic-input.js +4 -2
- package/lib/components/input-number/html/__snapshots__/input-number.spec.tsx.snap +38 -90
- package/lib/components/input-number/html/input-number-thousand.js +2 -0
- package/lib/components/input-number/html/input-number.js +3 -0
- package/lib/components/input-number/html/input-number.spec.js +35 -19
- package/lib/components/input-number/lunatic-input-number.js +2 -1
- package/lib/components/loop/{block-for-loop/block-for-loop.js → block-for-loop.js} +39 -64
- package/lib/components/loop/{commons/handle-row-button.js → loop-button.js} +4 -7
- package/lib/components/loop/{roster-for-loop/header.js → loop-header.js} +4 -8
- package/lib/components/loop/loop.js +19 -65
- package/lib/components/loop/roster-for-loop/roster-for-loop.js +102 -83
- package/lib/components/loop/{commons/get-init-length.js → utils/get-initial-nb-rows.js} +6 -5
- package/lib/components/{loop/roster-for-loop/body.js → lunatic-components.js} +46 -37
- package/lib/components/modal/html/modal.js +45 -73
- package/lib/components/modal/html/modal.scss +25 -42
- package/lib/components/modal/lunatic-modal.js +33 -9
- package/lib/components/modal-controls/close-or-skip.js +0 -1
- package/lib/components/modal-controls/modal-controls.spec.js +5 -6
- package/lib/components/pairwise-links/orchestrator.js +1 -4
- package/lib/components/pairwise-links/row.js +1 -4
- package/lib/components/question-explication/html/question-explication.js +0 -1
- package/lib/components/radio/html/radio-group-content.js +4 -3
- package/lib/components/radio/html/radio-group.js +4 -2
- package/lib/components/radio/html/radio-option.js +7 -8
- package/lib/components/radio/lunatic-radio-group.js +4 -2
- package/lib/components/roundabout/components/roundabout-it-title.js +0 -2
- package/lib/components/roundabout/components/roundabout-label.js +0 -2
- package/lib/components/roundabout/lunatic-roundabout.js +1 -4
- package/lib/components/roundabout/roundabout.js +0 -1
- package/lib/components/suggester/html/notification.js +0 -1
- package/lib/components/suggester/html/suggester.js +3 -3
- package/lib/components/suggester/idb-suggester/check-store.js +3 -5
- package/lib/components/suggester/idb-suggester/idb-suggester.js +4 -5
- package/lib/components/suggester/idb-suggester/suggester-notification.js +2 -2
- package/lib/components/suggester/lunatic-suggester.js +3 -1
- package/lib/components/suggester-loader-widget/loader-row.js +1 -4
- package/lib/components/suggester-loader-widget/loader.js +1 -3
- package/lib/components/summary/html/summary-responses.js +13 -7
- package/lib/components/summary/lunatic-summary.js +8 -4
- package/lib/components/switch/html/switch.js +0 -1
- package/lib/components/table/cell.js +0 -2
- package/lib/components/table/header.js +0 -2
- package/lib/components/table/row.js +0 -1
- package/lib/components/textarea/html/__snapshots__/textarea.spec.tsx.snap +30 -0
- package/lib/components/textarea/html/textarea.js +5 -6
- package/lib/components/textarea/html/textarea.spec.js +38 -0
- package/lib/components/textarea/lunatic-textarea.js +4 -2
- package/lib/index.js +8 -0
- package/lib/src/components/button/lunatic-button.d.ts +5 -3
- package/lib/src/components/checkbox/checkbox-boolean/html/checkbox-boolean.d.ts +2 -2
- package/lib/src/components/checkbox/checkbox-boolean/lunatic-checkbox-boolean.d.ts +1 -1
- package/lib/src/components/checkbox/checkbox-group/checkbox-group-content.d.ts +1 -1
- package/lib/src/components/checkbox/checkbox-group/html/checkbox-group-content.d.ts +1 -1
- package/lib/src/components/checkbox/checkbox-group/html/checkbox-group.d.ts +4 -4
- package/lib/src/components/checkbox/checkbox-group/lunatic-checkbox-group.d.ts +2 -2
- package/lib/src/components/checkbox/checkbox-one/html/checkbox-one.d.ts +1 -1
- package/lib/src/components/checkbox/checkbox-one/lunatic-checkbox-one.d.ts +1 -1
- package/lib/src/components/checkbox/commons/checkbox-option.d.ts +2 -2
- package/lib/src/components/commons/components/combo-box/combo-box-container.d.ts +1 -1
- package/lib/src/components/commons/components/combo-box/combo-box-content-box.d.ts +1 -1
- package/lib/src/components/commons/components/combo-box/combo-box-content.d.ts +1 -1
- package/lib/src/components/commons/components/combo-box/combo-box.d.ts +6 -5
- package/lib/src/components/commons/components/combo-box/combo-box.stories.d.ts +30 -2
- package/lib/src/components/commons/components/combo-box/combo-box.type.d.ts +1 -1
- package/lib/src/components/commons/components/combo-box/panel/combo-box-option.d.ts +1 -1
- package/lib/src/components/commons/components/combo-box/panel/panel-container.d.ts +1 -1
- package/lib/src/components/commons/components/combo-box/panel/panel.d.ts +2 -2
- package/lib/src/components/commons/components/combo-box/selection/LabelOrInput.d.ts +3 -2
- package/lib/src/components/commons/components/combo-box/selection/combo-box-label-selection.d.ts +2 -1
- package/lib/src/components/commons/components/combo-box/selection/input.d.ts +1 -1
- package/lib/src/components/commons/components/combo-box/selection/label-selection.d.ts +4 -3
- package/lib/src/components/commons/components/combo-box/selection/selection-container.d.ts +1 -1
- package/lib/src/components/commons/components/combo-box/selection/selection.d.ts +3 -2
- package/lib/src/components/commons/components/description.d.ts +1 -1
- package/lib/src/components/commons/components/dragger/dragger.d.ts +1 -1
- package/lib/src/components/commons/components/errors/errors.d.ts +1 -1
- package/lib/src/components/commons/components/fab/fab.d.ts +1 -1
- package/lib/src/components/commons/components/field-container/field-container.d.ts +1 -1
- package/lib/src/components/commons/components/fieldset.d.ts +3 -3
- package/lib/src/components/commons/components/html-table/table.d.ts +1 -1
- package/lib/src/components/commons/components/html-table/thead.d.ts +1 -1
- package/lib/src/components/commons/components/label/label.d.ts +1 -1
- package/lib/src/components/commons/components/lunatic-component-with-label.d.ts +2 -2
- package/lib/src/components/commons/components/lunatic-component-without-label.d.ts +2 -2
- package/lib/src/components/commons/components/md-label/link.d.ts +1 -1
- package/lib/src/components/commons/components/md-label/md-label.spec.d.ts +1 -0
- package/lib/src/components/commons/components/missing/missing.d.ts +1 -1
- package/lib/src/components/commons/components/orchestrated-component.d.ts +2 -2
- package/lib/src/components/commons/components/variable-status/variable-status.d.ts +1 -1
- package/lib/src/components/commons/create-customizable-field.d.ts +1 -1
- package/lib/src/components/commons/icons/checkbox-checked-icon.d.ts +1 -1
- package/lib/src/components/commons/icons/checkbox-unchecked-icon.d.ts +1 -1
- package/lib/src/components/commons/icons/closed-icon.d.ts +1 -1
- package/lib/src/components/commons/icons/cross-icon.d.ts +1 -1
- package/lib/src/components/commons/icons/load-icon.d.ts +1 -1
- package/lib/src/components/commons/icons/lunatic-icon.d.ts +1 -1
- package/lib/src/components/commons/icons/network-icon.d.ts +1 -1
- package/lib/src/components/commons/icons/on-drag-icon.d.ts +1 -1
- package/lib/src/components/commons/icons/opened-icon.d.ts +1 -1
- package/lib/src/components/commons/icons/radio-checked-icon.d.ts +1 -1
- package/lib/src/components/commons/icons/radio-unchecked-icon.d.ts +1 -1
- package/lib/src/components/commons/index.d.ts +0 -1
- package/lib/src/components/commons/safety-label.d.ts +1 -1
- package/lib/src/components/component-set/html/component-set-legend.d.ts +8 -0
- package/lib/src/components/component-set/html/component-set-wrapper.d.ts +6 -0
- package/lib/src/components/component-set/html/component-set.d.ts +5 -4
- package/lib/src/components/component-set/html/component-set.spec.d.ts +1 -0
- package/lib/src/components/component-set/lunatic-component-set.d.ts +3 -4
- package/lib/src/components/datepicker/html/datepicker-container.d.ts +1 -1
- package/lib/src/components/datepicker/html/datepicker-input.d.ts +1 -1
- package/lib/src/components/datepicker/html/datepicker.d.ts +3 -3
- package/lib/src/components/datepicker/html/datepicker.spec.d.ts +1 -0
- package/lib/src/components/datepicker/lunatic-datepicker.d.ts +2 -2
- package/lib/src/components/declarations/declaration.d.ts +1 -1
- package/lib/src/components/declarations/declarations-after-text.d.ts +1 -1
- package/lib/src/components/declarations/declarations-before-text.d.ts +1 -1
- package/lib/src/components/declarations/declarations-detachable.d.ts +1 -1
- package/lib/src/components/declarations/declarations.d.ts +1 -1
- package/lib/src/components/dropdown/html/dropdown-simple/dropdown-simple.d.ts +2 -2
- package/lib/src/components/dropdown/html/dropdown-simple/simple-label-renderer.d.ts +1 -1
- package/lib/src/components/dropdown/html/dropdown-simple/simple-option-renderer.d.ts +1 -1
- package/lib/src/components/dropdown/html/dropdown-writable/dropdown-writable.d.ts +5 -4
- package/lib/src/components/dropdown/html/dropdown-writable/writable-label-renderer.d.ts +1 -1
- package/lib/src/components/dropdown/html/dropdown-writable/writable-option-renderer.d.ts +1 -1
- package/lib/src/components/dropdown/html/dropdown.d.ts +4 -3
- package/lib/src/components/dropdown/html/dropdown.spec.d.ts +1 -0
- package/lib/src/components/dropdown/lunatic-dropdown.d.ts +2 -2
- package/lib/src/components/duration/duration.d.ts +1 -1
- package/lib/src/components/duration/durationInput.d.ts +1 -1
- package/lib/src/components/duration/formatDuration.d.ts +1 -1
- package/lib/src/components/duration/getDurationFromValue.d.ts +1 -1
- package/lib/src/components/duration/index.d.ts +1 -1
- package/lib/src/components/filter-description/component.d.ts +2 -2
- package/lib/src/components/index.d.ts +4 -4
- package/lib/src/components/input/html/input.d.ts +4 -3
- package/lib/src/components/input/html/input.spec.d.ts +1 -0
- package/lib/src/components/input/lunatic-input.d.ts +1 -1
- package/lib/src/components/input-number/html/input-number-thousand.d.ts +2 -1
- package/lib/src/components/input-number/html/input-number.d.ts +3 -2
- package/lib/src/components/input-number/lunatic-input-number.d.ts +1 -1
- package/lib/src/components/loop/{block-for-loop/block-for-loop.d.ts → block-for-loop.d.ts} +6 -4
- package/lib/src/components/loop/loop-button.d.ts +7 -0
- package/lib/src/components/loop/loop-header.d.ts +9 -0
- package/lib/src/components/loop/loop.d.ts +2 -3
- package/lib/src/components/loop/roster-for-loop/roster-for-loop.d.ts +7 -5
- package/lib/src/components/loop/utils/get-initial-nb-rows.d.ts +4 -0
- package/lib/src/components/lunatic-components.d.ts +13 -0
- package/lib/src/components/modal/html/modal.d.ts +10 -13
- package/lib/src/components/modal/lunatic-modal.d.ts +2 -2
- package/lib/src/components/modal-controls/close-or-skip.d.ts +1 -1
- package/lib/src/components/modal-controls/modal-container.d.ts +1 -1
- package/lib/src/components/modal-controls/modal-controls.d.ts +2 -2
- package/lib/src/components/pairwise-links/orchestrator.d.ts +1 -1
- package/lib/src/components/pairwise-links/pairwise-links.d.ts +1 -1
- package/lib/src/components/pairwise-links/row.d.ts +1 -1
- package/lib/src/components/question-explication/html/question-explication.d.ts +1 -1
- package/lib/src/components/question-explication/lunatic-question-explication.d.ts +1 -1
- package/lib/src/components/radio/html/radio-group-content.d.ts +3 -2
- package/lib/src/components/radio/html/radio-group.d.ts +3 -2
- package/lib/src/components/radio/html/radio-option.d.ts +3 -2
- package/lib/src/components/roundabout/components/roundabout-it-title.d.ts +3 -3
- package/lib/src/components/roundabout/components/roundabout-label.d.ts +3 -3
- package/lib/src/components/roundabout/lunatic-roundabout.d.ts +1 -1
- package/lib/src/components/roundabout/roundabout.d.ts +2 -2
- package/lib/src/components/sequence/html/sequence.d.ts +1 -1
- package/lib/src/components/sequence/lunatic-sequence.d.ts +2 -2
- package/lib/src/components/suggester/html/notification.d.ts +2 -2
- package/lib/src/components/suggester/html/suggester.d.ts +6 -5
- package/lib/src/components/suggester/idb-suggester/check-store.d.ts +1 -1
- package/lib/src/components/suggester/idb-suggester/idb-suggester.d.ts +3 -3
- package/lib/src/components/suggester/idb-suggester/suggester-notification.d.ts +1 -1
- package/lib/src/components/suggester/idb-suggester/suggester-status.d.ts +1 -1
- package/lib/src/components/suggester/lunatic-suggester.d.ts +2 -2
- package/lib/src/components/suggester/searching/create-searching.d.ts +1 -1
- package/lib/src/components/suggester-loader-widget/loader-row.d.ts +1 -1
- package/lib/src/components/suggester-loader-widget/loader.d.ts +1 -1
- package/lib/src/components/suggester-loader-widget/tools/action-tool.d.ts +1 -1
- package/lib/src/components/suggester-loader-widget/tools/tools.d.ts +1 -1
- package/lib/src/components/suggester-loader-widget/widget.d.ts +1 -1
- package/lib/src/components/summary/html/summary-container.d.ts +1 -1
- package/lib/src/components/summary/html/summary-responses.d.ts +3 -1
- package/lib/src/components/summary/html/summary-title.d.ts +1 -1
- package/lib/src/components/summary/lunatic-summary.d.ts +3 -2
- package/lib/src/components/switch/html/switch.d.ts +3 -3
- package/lib/src/components/switch/lunatic-switch.d.ts +1 -1
- package/lib/src/components/table/cell.d.ts +1 -1
- package/lib/src/components/table/header.d.ts +1 -1
- package/lib/src/components/table/lunatic-table.d.ts +1 -1
- package/lib/src/components/table/row.d.ts +1 -1
- package/lib/src/components/table/table-orchestrator.d.ts +1 -1
- package/lib/src/components/textarea/html/textarea.d.ts +4 -3
- package/lib/src/components/textarea/html/textarea.spec.d.ts +1 -0
- package/lib/src/components/textarea/lunatic-textarea.d.ts +1 -1
- package/lib/src/components/type.d.ts +9 -6
- package/lib/src/i18n/build-dictionary.d.ts +1 -1
- package/lib/src/index.d.ts +1 -0
- package/lib/src/use-lunatic/actions.d.ts +4 -8
- package/lib/src/use-lunatic/commons/calculated-variables.d.ts +1 -1
- package/lib/src/use-lunatic/commons/check-loops.d.ts +1 -1
- package/lib/src/use-lunatic/commons/check-pager.d.ts +1 -1
- package/lib/src/use-lunatic/commons/compile-controls.d.ts +1 -1
- package/lib/src/use-lunatic/commons/compose.d.ts +1 -1
- package/lib/src/use-lunatic/commons/create-map-pages.d.ts +2 -2
- package/lib/src/use-lunatic/commons/execute-condition-filter.d.ts +1 -1
- package/lib/src/use-lunatic/commons/execute-expression/create-execute-expression.d.ts +1 -1
- package/lib/src/use-lunatic/commons/execute-expression/create-refresh-calculated.d.ts +2 -2
- package/lib/src/use-lunatic/commons/execute-expression/execute-expression.d.ts +3 -3
- package/lib/src/use-lunatic/commons/execute-expression/get-safety-expression.d.ts +1 -1
- package/lib/src/use-lunatic/commons/fill-components/fill-component-expressions.d.ts +5 -2
- package/lib/src/use-lunatic/commons/fill-components/fill-component-value.d.ts +1 -1
- package/lib/src/use-lunatic/commons/fill-components/fill-components.d.ts +15 -10
- package/lib/src/use-lunatic/commons/fill-components/fill-from-state.d.ts +38 -1
- package/lib/src/use-lunatic/commons/fill-components/fill-management.d.ts +1 -1
- package/lib/src/use-lunatic/commons/fill-components/fill-missing-response.d.ts +1 -1
- package/lib/src/use-lunatic/commons/fill-components/fill-pagination.d.ts +1 -1
- package/lib/src/use-lunatic/commons/fill-components/fill-specific-expression.d.ts +62 -33
- package/lib/src/use-lunatic/commons/get-compatible-vtl-expression.d.ts +1 -1
- package/lib/src/use-lunatic/commons/get-component-value/get-component-value.d.ts +1 -1
- package/lib/src/use-lunatic/commons/get-components-from-state.d.ts +1 -2
- package/lib/src/use-lunatic/commons/get-data.d.ts +1 -1
- package/lib/src/use-lunatic/commons/get-errors-without-empty-value.d.ts +1 -1
- package/lib/src/use-lunatic/commons/getOverview.d.ts +1 -1
- package/lib/src/use-lunatic/commons/is-First-last-page.d.ts +1 -1
- package/lib/src/use-lunatic/commons/is-paginated-loop.d.ts +1 -1
- package/lib/src/use-lunatic/commons/is-roundabout.d.ts +1 -1
- package/lib/src/use-lunatic/commons/page-navigation.d.ts +2 -2
- package/lib/src/use-lunatic/commons/page-tag.d.ts +1 -1
- package/lib/src/use-lunatic/commons/page.d.ts +2 -2
- package/lib/src/use-lunatic/commons/use-components-from-state.d.ts +2 -2
- package/lib/src/use-lunatic/hooks/use-loop-variables.d.ts +1 -1
- package/lib/src/use-lunatic/lunatic-context.d.ts +1 -1
- package/lib/src/use-lunatic/reducer/commons/auto-explore-loop.d.ts +1 -1
- package/lib/src/use-lunatic/reducer/commons/is-loop-component.d.ts +3 -3
- package/lib/src/use-lunatic/reducer/commons/validate-condition-filter.d.ts +1 -1
- package/lib/src/use-lunatic/reducer/overview/overview-on-change.d.ts +1 -1
- package/lib/src/use-lunatic/reducer/overview/overview-on-init.d.ts +2 -2
- package/lib/src/use-lunatic/reducer/reduce-go-next-page.d.ts +2 -4
- package/lib/src/use-lunatic/reducer/reduce-go-next-page.spec.d.ts +1 -0
- package/lib/src/use-lunatic/reducer/reduce-go-previous-page.d.ts +1 -1
- package/lib/src/use-lunatic/reducer/reduce-go-previous-page.spec.d.ts +1 -0
- package/lib/src/use-lunatic/reducer/reduce-go-to-page.d.ts +2 -2
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-cleaning.d.ts +2 -2
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-handle-change.d.ts +2 -2
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-links-variable.d.ts +2 -2
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-missing.d.ts +2 -2
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-resizing.d.ts +2 -2
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-variables-array.d.ts +1 -1
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-variables-simple.d.ts +1 -1
- package/lib/src/use-lunatic/reducer/reduce-on-init.d.ts +2 -2
- package/lib/src/use-lunatic/reducer/reduce-on-set-waiting.d.ts +2 -2
- package/lib/src/use-lunatic/reducer/reduce-update-state.d.ts +2 -2
- package/lib/src/use-lunatic/reducer/reducer.d.ts +2 -2
- package/lib/src/use-lunatic/reducer/resolve-component-controls/resolve-component-control.d.ts +2 -2
- package/lib/src/use-lunatic/reducer/resolve-component-controls/resolve-roundabout-control.d.ts +2 -2
- package/lib/src/use-lunatic/reducer/resolve-component-controls/resolve-simple-control.d.ts +2 -2
- package/lib/src/use-lunatic/replace-component-sequence.d.ts +3 -1
- package/lib/src/use-lunatic/type-source.d.ts +3 -1
- package/lib/src/use-lunatic/type.d.ts +3 -3
- package/lib/src/use-lunatic/use-lunatic.d.ts +21 -15
- package/lib/src/use-lunatic/use-suggesters.d.ts +1 -1
- package/lib/src/utils/array.d.ts +8 -0
- package/lib/src/utils/dom.d.ts +14 -0
- package/lib/src/utils/get-component-value.d.ts +1 -1
- package/lib/src/utils/get-component-value.test.d.ts +1 -0
- package/lib/src/utils/is-element.d.ts +1 -1
- package/lib/src/utils/number.d.ts +5 -0
- package/lib/src/utils/number.spec.d.ts +1 -0
- package/lib/src/utils/store-tools/initStore.d.ts +1 -1
- package/lib/src/utils/suggester-workers/append-to-index/create-append-task.d.ts +1 -1
- package/lib/src/utils/suggester-workers/searching/compute-score.d.ts +1 -1
- package/lib/stories/checkbox-one/source.json +2 -2
- package/lib/stories/component-set/component-set.stories.js +9 -9
- package/lib/stories/component-set/{data2.json → data-roundabout.json} +1 -1
- package/lib/stories/component-set/data.json +8 -1
- package/lib/stories/component-set/source-loop.json +308 -0
- package/lib/stories/component-set/source-roundabout.json +434 -0
- package/lib/stories/component-set/source.json +16 -2
- package/lib/stories/disabled/data.json +32 -0
- package/lib/{components/commons/components/combo-box/state-management/reduce-on-keydown/on-end.js → stories/disabled/disabled.stories.js} +25 -12
- package/lib/stories/disabled/source.json +382 -0
- package/lib/stories/input/source-with-question.json +9 -3
- package/lib/stories/input/source.json +6 -0
- package/lib/stories/loop/source-paginated.json +2 -2
- package/lib/stories/overview/source.json +1 -1
- package/lib/stories/overview/sourceWithHierarchy.json +10 -2
- package/lib/stories/pairwise/links-componentset.json +292 -0
- package/lib/stories/pairwise/pairwise-links.stories.js +11 -2
- package/lib/stories/question-explication/source.json +16 -16
- package/lib/stories/questionnaires/logement/source-sum.json +31805 -34611
- package/lib/stories/questionnaires/recensement/source.json +2 -2
- package/lib/stories/questionnaires/simpsons/simpsons.stories.js +4 -4
- package/lib/stories/questionnaires-test/V2_DeclarationsSimples.json +963 -847
- package/lib/stories/questionnaires-test/V2_QuestSimple_Boucles.json +4350 -4090
- package/lib/stories/suggester/simple.json +4 -0
- package/lib/stories/summary/source.json +55 -40
- package/lib/stories/utils/orchestrator.js +11 -22
- package/lib/tests/utils/lunatic.d.ts +16 -2
- package/lib/use-lunatic/commons/execute-expression/create-execute-expression.js +13 -45
- package/lib/use-lunatic/commons/execute-expression/execute-expression.js +0 -1
- package/lib/use-lunatic/commons/fill-components/fill-component-expressions.js +5 -1
- package/lib/use-lunatic/commons/fill-components/fill-components.js +10 -2
- package/lib/use-lunatic/commons/fill-components/fill-from-state.js +3 -0
- package/lib/use-lunatic/commons/fill-components/fill-specific-expression.js +66 -21
- package/lib/use-lunatic/commons/get-component-value/get-component-value.js +1 -3
- package/lib/use-lunatic/commons/page.js +6 -0
- package/lib/use-lunatic/hooks/use-loop-variables.js +1 -1
- package/lib/use-lunatic/reducer/reduce-go-next-page.js +10 -10
- package/lib/use-lunatic/reducer/reduce-go-next-page.spec.js +13 -0
- package/lib/use-lunatic/reducer/reduce-go-previous-page.js +3 -3
- package/lib/use-lunatic/reducer/reduce-go-previous-page.spec.js +14 -0
- package/lib/use-lunatic/reducer/reduce-go-to-page.js +3 -8
- package/lib/use-lunatic/reducer/reduce-handle-change/__mocks__/source-cleaning-loop.json +790 -924
- package/lib/use-lunatic/reducer/reducer.js +2 -2
- package/lib/use-lunatic/use-lunatic.js +5 -2
- package/lib/use-lunatic/use-lunatic.test.js +26 -0
- package/lib/utils/array.js +33 -0
- package/lib/utils/dom.js +27 -0
- package/lib/utils/get-component-value.js +13 -11
- package/lib/utils/get-component-value.test.js +57 -0
- package/lib/utils/number.js +30 -0
- package/lib/utils/number.spec.js +11 -0
- package/lib/utils/suggester-workers/commons-tokenizer/filters/filter-synonyms.spec.js +0 -2
- package/package.json +9 -3
- package/lib/components/commons/components/combo-box/state-management/actions.js +0 -79
- package/lib/components/commons/components/combo-box/state-management/index.js +0 -25
- package/lib/components/commons/components/combo-box/state-management/reduce-on-init.js +0 -38
- package/lib/components/commons/components/combo-box/state-management/reduce-on-keydown/on-arrow-down.js +0 -30
- package/lib/components/commons/components/combo-box/state-management/reduce-on-keydown/on-arrow-up.js +0 -30
- package/lib/components/commons/components/combo-box/state-management/reduce-on-keydown/on-enter.js +0 -19
- package/lib/components/commons/components/combo-box/state-management/reduce-on-keydown/on-escape.js +0 -18
- package/lib/components/commons/components/combo-box/state-management/reduce-on-keydown/on-home.js +0 -23
- package/lib/components/commons/components/combo-box/state-management/reduce-on-keydown/on-tab.js +0 -18
- package/lib/components/commons/components/combo-box/state-management/reduce-on-keydown/reduce-on-keydown.js +0 -40
- package/lib/components/commons/components/combo-box/state-management/reducer.js +0 -53
- package/lib/components/commons/create-row-orchestrator.js +0 -58
- package/lib/components/component-set/html/component-set-component-container.js +0 -20
- package/lib/components/component-set/html/component-set-components.js +0 -45
- package/lib/components/component-set/html/legend/index.js +0 -13
- package/lib/components/component-set/index.js +0 -13
- package/lib/components/loop/block-for-loop/block-for-loop-ochestrator.js +0 -12
- package/lib/components/loop/block-for-loop/index.js +0 -13
- package/lib/components/loop/block-for-loop/row.js +0 -56
- package/lib/components/loop/commons/index.js +0 -20
- package/lib/components/loop/commons/row-component.js +0 -72
- package/lib/components/loop/index.js +0 -13
- package/lib/components/loop/roster-for-loop/index.js +0 -13
- package/lib/components/loop/roster-for-loop/roster-for-loop-orchestrator.js +0 -12
- package/lib/components/loop/roster-for-loop/roster-table.js +0 -50
- package/lib/components/loop/roster-for-loop/row.js +0 -85
- package/lib/src/components/commons/components/combo-box/state-management/actions.d.ts +0 -78
- package/lib/src/components/commons/components/combo-box/state-management/index.d.ts +0 -9
- package/lib/src/components/commons/components/combo-box/state-management/reduce-on-init.d.ts +0 -4
- package/lib/src/components/commons/components/combo-box/state-management/reduce-on-keydown/on-arrow-down.d.ts +0 -2
- package/lib/src/components/commons/components/combo-box/state-management/reduce-on-keydown/on-arrow-up.d.ts +0 -2
- package/lib/src/components/commons/components/combo-box/state-management/reduce-on-keydown/on-end.d.ts +0 -2
- package/lib/src/components/commons/components/combo-box/state-management/reduce-on-keydown/on-enter.d.ts +0 -2
- package/lib/src/components/commons/components/combo-box/state-management/reduce-on-keydown/on-escape.d.ts +0 -2
- package/lib/src/components/commons/components/combo-box/state-management/reduce-on-keydown/on-home.d.ts +0 -2
- package/lib/src/components/commons/components/combo-box/state-management/reduce-on-keydown/on-tab.d.ts +0 -2
- package/lib/src/components/commons/components/combo-box/state-management/reduce-on-keydown/reduce-on-keydown.d.ts +0 -9
- package/lib/src/components/commons/components/combo-box/state-management/reducer.d.ts +0 -3
- package/lib/src/components/commons/create-row-orchestrator.d.ts +0 -32
- package/lib/src/components/component-set/html/component-set-component-container.d.ts +0 -6
- package/lib/src/components/component-set/html/component-set-components.d.ts +0 -7
- package/lib/src/components/component-set/html/legend/index.d.ts +0 -1
- package/lib/src/components/component-set/html/legend/legend.d.ts +0 -8
- package/lib/src/components/component-set/index.d.ts +0 -1
- package/lib/src/components/loop/block-for-loop/block-for-loop-ochestrator.d.ts +0 -51
- package/lib/src/components/loop/block-for-loop/index.d.ts +0 -1
- package/lib/src/components/loop/block-for-loop/row.d.ts +0 -23
- package/lib/src/components/loop/commons/get-init-length.d.ts +0 -2
- package/lib/src/components/loop/commons/handle-row-button.d.ts +0 -7
- package/lib/src/components/loop/commons/index.d.ts +0 -2
- package/lib/src/components/loop/commons/row-component.d.ts +0 -9
- package/lib/src/components/loop/index.d.ts +0 -1
- package/lib/src/components/loop/roster-for-loop/body.d.ts +0 -12
- package/lib/src/components/loop/roster-for-loop/header.d.ts +0 -9
- package/lib/src/components/loop/roster-for-loop/index.d.ts +0 -1
- package/lib/src/components/loop/roster-for-loop/roster-for-loop-orchestrator.d.ts +0 -51
- package/lib/src/components/loop/roster-for-loop/roster-table.d.ts +0 -13
- package/lib/src/components/loop/roster-for-loop/row.d.ts +0 -24
- package/lib/stories/component-set/source1.json +0 -287
- package/lib/stories/component-set/source2.json +0 -413
- /package/lib/components/commons/components/combo-box/{state-management/reduce-on-keydown/keyboard-key-codes.js → keyboard-key-codes.js} +0 -0
- /package/lib/src/components/commons/components/combo-box/{state-management/reduce-on-keydown/keyboard-key-codes.d.ts → keyboard-key-codes.d.ts} +0 -0
- /package/lib/stories/component-set/{data1.json → data-loop.json} +0 -0
package/README.fr.md
ADDED
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
<img align="right" src="docs/img/lunatic-logo.png" alt="Lunatic logo"/>
|
|
2
|
+
|
|
3
|
+
# Lunatic
|
|
4
|
+
|
|
5
|
+
[](https://github.com/InseeFr/Lunatic/actions/workflows/quality.yml)
|
|
6
|
+
[](https://badge.fury.io/js/%40inseefr%2Flunatic)
|
|
7
|
+
[](https://sonarcloud.io/dashboard?id=InseeFr_Lunatic)
|
|
8
|
+
[](https://sonarcloud.io/dashboard?id=InseeFr_Lunatic)
|
|
9
|
+
[](https://opensource.org/licenses/MIT)
|
|
10
|
+
|
|
11
|
+
Lunatic est une librairie front-end sous forme de hook react et de librairies de composants pour générer un questionnaire à partir du format de données [Lunatic-Model](https://github.com/InseeFr/Lunatic-Model).
|
|
12
|
+
|
|
13
|
+
- [Storybook](https://inseefr.github.io/Lunatic/storybook), branche `main`
|
|
14
|
+
- [Storybook v1](https://inseefr.github.io/Lunatic/storybook-v1), branche `v1-main`
|
|
15
|
+
- [Storybook Beta](https://inseefr.github.io/Lunatic/storybook-beta), branche `develop`
|
|
16
|
+
- [Documentation](https://inseefr.github.io/Lunatic/fr/)
|
|
17
|
+
|
|
18
|
+
## Sommaire
|
|
19
|
+
|
|
20
|
+
- [Lunatic](#lunatic)
|
|
21
|
+
- [Sommaire](#sommaire)
|
|
22
|
+
- [Utilisation](#utilisation)
|
|
23
|
+
- [Le hook useLunatic](#le-hook-uselunatic)
|
|
24
|
+
- [Les composants](#les-composants)
|
|
25
|
+
- [Personnalisation](#personnalisation)
|
|
26
|
+
- [Fonctionnement interne](#fonctionnement-interne)
|
|
27
|
+
- [Fonctionnement général](#fonctionnement-général)
|
|
28
|
+
- [pages et pager](#pages-et-pager)
|
|
29
|
+
- [Exécution du VTL](#exécution-du-vtl)
|
|
30
|
+
- [Convention et Bonnes Pratiques](#convention-et-bonnes-pratiques)
|
|
31
|
+
|
|
32
|
+
## Utilisation
|
|
33
|
+
|
|
34
|
+
Pour commencer il faut installer lunatic
|
|
35
|
+
|
|
36
|
+
```bash
|
|
37
|
+
yarn add @inseefr/lunatic
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
### Le hook useLunatic
|
|
41
|
+
|
|
42
|
+
Ensuite, à l'endroit où vous souhaitez afficher le formulaire il faudra utiliser le hook `useLunatic`.
|
|
43
|
+
|
|
44
|
+
```js
|
|
45
|
+
import { useLunatic } from '@inseefr/lunatic';
|
|
46
|
+
|
|
47
|
+
const obj = useLunatic(source, data, options);
|
|
48
|
+
```
|
|
49
|
+
|
|
50
|
+
Ce hook prend 3 paramètres :
|
|
51
|
+
|
|
52
|
+
- La **source**, qui est une représentation JSON du [Lunatic-Model](https://github.com/InseeFr/Lunatic-Model).
|
|
53
|
+
- Les **données**, qui contient les données initiales du questionnaires (peut être un objet vide)
|
|
54
|
+
- Un objet d'option pour paramétrer le fonctionnement
|
|
55
|
+
- **features** (défaut `['VTL', 'MD']`), permet de définir les fonctionnalité supportées
|
|
56
|
+
- **preferences** (défaut `['COLLECTED']`)
|
|
57
|
+
- **onChange** (défaut `() => {}`), permet d'ajouter une logique à appliquer lorsqu'une réponse est modifiée (doit être mémoïsé car est utilisé comme dépendance d'un useCallback en interne)
|
|
58
|
+
- **management** (défaut `false`) : Non implémenté encore, permettra de gérer plusieurs état d'une même variable (utilisation par des postes de reprise)
|
|
59
|
+
- **initialPage** (défaut `'1'`), permet de définir la page de départ
|
|
60
|
+
- **lastReachedPage** (défaut `undefined`) permet de définir quelle est la page la plus lointaine déjà atteinte
|
|
61
|
+
- **autoSuggesterLoading** (défaut `false`)
|
|
62
|
+
- **suggesters**
|
|
63
|
+
- **suggesterFetcher** (défaut `fetch`), méthode utilisée pour récupérer les données du suggester
|
|
64
|
+
- **activeControls** (défaut `false`), active les contrôles de données
|
|
65
|
+
|
|
66
|
+
Et retourne un objet permettant de piloter le questionnaire :
|
|
67
|
+
|
|
68
|
+
- `getComponents()`, renvoie les composants à afficher pour la page courante
|
|
69
|
+
- `goPreviousPage()`, permet d'aller à la page précédente
|
|
70
|
+
- `goNextPage()`, permet d'aller à la page suivante
|
|
71
|
+
- `goToPage({ page: string })`, permet d'aller à une page arbitraire
|
|
72
|
+
- `getErrors()`, renvoie les erreurs
|
|
73
|
+
- `getModalErrors()`, renvoie les erreurs dans les modales
|
|
74
|
+
- `getCurrentErrors()`, renvoie les erreurs de la page courante
|
|
75
|
+
- `pageTag`, une chaine de caractère contenant le numéro de page (ex: 8.1)
|
|
76
|
+
- `isFirstPage`
|
|
77
|
+
- `isLastPage`
|
|
78
|
+
- `pager`, un objet contenant les informations liées à la page
|
|
79
|
+
- `waiting`, indique une attente d'information de la part d'un suggester
|
|
80
|
+
- `getData()`, renvoie les données collectées dans le questionnaire
|
|
81
|
+
- `loopVariables`, est un tableau contenant la liste des variables utilisées pour la boucle courante
|
|
82
|
+
|
|
83
|
+
Pour plus d'informations sur les types de ce retour vous pouvez vous référer aux types disponibles dans le [code source](https://github.com/InseeFr/Lunatic/blob/v2-typescript/src/use-lunatic/type.ts#L64-L200). Vous pouvez aussi trouver un exemple d'utilisation du hook dans la partie [Storybook](https://github.com/InseeFr/Lunatic/blob/v2-develop/src/stories/utils/orchestrator.js#L69-L93).
|
|
84
|
+
|
|
85
|
+
### Les composants
|
|
86
|
+
|
|
87
|
+
Pour afficher le questionnaire on commencera par récupérer la liste des composants à afficher à l'aide de la méthode `getComponents()` renvoyée par le hook.
|
|
88
|
+
|
|
89
|
+
Ensuite, on pourra utiliser le composant `<LunaticComponents />` pour gérer l'affichage des composants
|
|
90
|
+
|
|
91
|
+
```jsx
|
|
92
|
+
import { LunaticComponents } from '@inseefr/lunatic';
|
|
93
|
+
|
|
94
|
+
function App({ source, data }) {
|
|
95
|
+
const { getComponents, getCurrentErrors, getModalErrors } =
|
|
96
|
+
lunatic.useLunatic(source, data, {});
|
|
97
|
+
const components = getComponents();
|
|
98
|
+
const currentErrors = getCurrentErrors();
|
|
99
|
+
const modalErrors = getModalErrors();
|
|
100
|
+
|
|
101
|
+
return (
|
|
102
|
+
<div className="container">
|
|
103
|
+
<LunaticComponents components={components} />
|
|
104
|
+
<lunatic.Modal errors={modalErrors} goNext={goNextPage} />
|
|
105
|
+
</div>
|
|
106
|
+
);
|
|
107
|
+
}
|
|
108
|
+
```
|
|
109
|
+
|
|
110
|
+
Ce composant se charge de récupérer le bon composant à afficher en fonction des champs demandés. Il est possible de personnaliser les propriétés passées aux composants grâce à la propriété `componentProps` mais aussi de rajouter un élément autour de chaque composant grâce à la méthode `wrapper`. Vous pouvez regarder [l'orchestrateur du storybook](./src/stories/utils/orchestrator.jsx) pour avoir un exemple d'utilisation.
|
|
111
|
+
|
|
112
|
+
Pour activer l'**autofocus**, il faut passer une clé dans la propriété `autoFocusKey` de `LunaticComponents`. Dès que cette valeur change, le premier champ est focus (une bonne solution est de passer le pageTag fourni par useLunatic).
|
|
113
|
+
|
|
114
|
+
## Personnalisation
|
|
115
|
+
|
|
116
|
+
Par défaut les composants offerts par Lunatic sont plutôt simples avec un style minimal. Il est possible de personnaliser les champs avec votre propre CSS, mais pour des cas plus complexes, vous pouvez aussi remplacer les composants de bases à l'aide de la propriété `custom` que vous pouvez passer lors de l'appel à useLunatic.
|
|
117
|
+
|
|
118
|
+
```jsx
|
|
119
|
+
const custom = {
|
|
120
|
+
Input: MyCustomInput,
|
|
121
|
+
InputNumber: MyCustomInputNumber,
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
function App({ source, data }) {
|
|
125
|
+
const {} = useLunatic(source, data, { custom });
|
|
126
|
+
|
|
127
|
+
// ...
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Fonctionnement interne
|
|
132
|
+
|
|
133
|
+
Cette partie concerne le fonctionnement interne du hook `useLunatic()`. L'objectif est d'aider à la compréhension de son fonctionnement.
|
|
134
|
+
|
|
135
|
+
### Fonctionnement général
|
|
136
|
+
|
|
137
|
+
Le hook se base sur un [état interne](https://github.com/InseeFr/Lunatic/blob/v2-typescript/src/use-lunatic/type.ts#L64-L200) qui est mis à jour au travers d'un système de [reducer](https://reactjs.org/docs/hooks-reference.html#usereducer). Les [actions](https://github.com/InseeFr/Lunatic/blob/v2-typescript/src/use-lunatic/actions.ts) qui affectent cet état sont limitées
|
|
138
|
+
|
|
139
|
+
- Une action `'use-lunatic/on-init'` permet l'initialisation de l'état à partir des données reçu en paramètre du hook.
|
|
140
|
+
- Les actions `'use-lunatic/go-previous'`, `'use-lunatic/go-next'` et `'use-lunatic/go-to-page'` sont appelées lors de la navigation à l'aide des méthodes renvoyées par le hook
|
|
141
|
+
- L'action `use-lunatic/handle-change` est l'action la plus importante qui est appelée dès lors qu'une donnée est changée dans le questionnaire.
|
|
142
|
+
|
|
143
|
+
L'ensemble des [reducers correspondants à ces actions sont disponibles ici](https://github.com/InseeFr/Lunatic/blob/v2-develop/src/use-lunatic/reducer/reducer.js). En général, ils sont décomposés en plusieurs méthodes en fonction de la partie de l'état qu'ils modifient.
|
|
144
|
+
|
|
145
|
+
### pages et pager
|
|
146
|
+
|
|
147
|
+
À l'initialisation le scénario du questionnaire est modélisé sous forme d'un objet qui est stocké dans l'état (dans la propriété `pages`). Cet objet est indexé par numéro de page et contient la liste des composants à afficher pour chaque page. Combiné au `pager` qui contient l'état de la navigation, c'est cette propriété qui permet de résoudre les composants à afficher.
|
|
148
|
+
|
|
149
|
+
### Exécution du VTL
|
|
150
|
+
|
|
151
|
+
L'autre point important de lunatic est l'exécution des expressions VTL qui permettent de rendre certaines propriétés dynamiques (libellés, erreurs...). Ce remplissage se fait [lorsque l'état change](https://github.com/InseeFr/Lunatic/blob/v2-develop/src/use-lunatic/commons/use-components-from-state.js).
|
|
152
|
+
|
|
153
|
+
Afin de faciliter l'exécution des expressions une méthode `executeExpression()` est exposée dans l'état de Lunatic. Cette méthode est accompagnée d'une méthode `updateBindings()` qui permet la mise à jour des valeurs internes. Ce système d'exécution d'expression utilise un système de mémorisation pour ne pas re-exécuter une même expression plusieurs fois. Lorsque l'action `use-lunatic/handle-change` est exécuté, les valeurs ("bindings") sont mis à jour pour mémoriser les valeurs associées aux différentes variables VTL. De la même manière les valeurs des variables calculées dont dépend la variable modifié sont oubliées afin de rafraichir la valeur lors de la prochaine exécution.
|
|
154
|
+
|
|
155
|
+
## Convention et Bonnes Pratiques
|
|
156
|
+
|
|
157
|
+
- On évite les exports "défaut" car cela nuit à la lisibilité lors de l'import.
|
|
158
|
+
- Les commentaires dans le code sont en anglais.
|
|
159
|
+
- Les fichiers contenant du JSX doivent utiliser l'extension .jsx (ou .tsx).
|
|
160
|
+
- Les commits suivent la spécification [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).
|
|
161
|
+
- Les Pull Requests doivent être préfixées comme les commits avec la même convention :
|
|
162
|
+
|
|
163
|
+
- `test(XXX?)` : XXX pour de l'ajout de tests.
|
|
164
|
+
- `feat(XXX?)` : XXX pour de l'ajout de fonctionnalités.
|
|
165
|
+
- `fix(XXX?)` : XXX pour de la correction de bug.
|
|
166
|
+
- `docs(XXX?)` : XXX pour de l'ajout de documentation.
|
|
167
|
+
- `refactor(XXX?)` : XXX pour du refactoring qui ne change pas de fonctionnalités.
|
|
168
|
+
- `build(XXX?)` : XXX pour des changements liés au processus de build, aux scripts de compilation, etc.
|
|
169
|
+
- `style(XXX?)` : XXX pour de la modification de style.
|
|
170
|
+
- `ci(XXX?)` : XXX pour de la modification de CI.
|
|
171
|
+
- `perf(XXX?)` : XXX pour de l'amélioration de performance.
|
|
172
|
+
- `revert(XXX?)` : XXX pour annuler une précédente PR.
|
|
173
|
+
- `chore(XXX?)` : XXX pour des tâches de maintenance ou des tâches qui ne rentrent pas dans les autres catégories.
|
|
174
|
+
|
|
175
|
+
- Les branches doivent être préfixées (on suivra les mêmes préfixes que pour le Conventional Commits) :
|
|
176
|
+
- `test/XXX` : pour de l'ajout de tests.
|
|
177
|
+
- `feat/XXX` : pour de l'ajout de fonctionnalités.
|
|
178
|
+
- `fix/XXX` : pour de la correction de bug.
|
|
179
|
+
- `docs/XXX` : pour de l'ajout de documentation.
|
|
180
|
+
- `refactor/XXX` : pour du refactoring qui ne change pas de fonctionnalités.
|
|
181
|
+
- `build/XXX` : pour des changements liés au processus de build, aux scripts de compilation, etc.
|
|
182
|
+
- `style/XXX` : pour des changements liés au style du code.
|
|
183
|
+
- `ci/XXX` : pour des changements liés à l'intégration continue (CI).
|
|
184
|
+
- `perf/XXX` : pour des améliorations de performance.
|
|
185
|
+
- `revert/XXX` : pour annuler une précédente PR.
|
|
186
|
+
- `chore/XXX` : pour des tâches de maintenance ou des tâches qui ne rentrent pas dans les autres catégories.
|
package/README.md
CHANGED
|
@@ -8,38 +8,38 @@
|
|
|
8
8
|
[](https://sonarcloud.io/dashboard?id=InseeFr_Lunatic)
|
|
9
9
|
[](https://opensource.org/licenses/MIT)
|
|
10
10
|
|
|
11
|
-
Lunatic
|
|
11
|
+
Lunatic is a front-end library in the form of a React hook and component libraries for generating a questionnaire from the [Lunatic-Model](https://github.com/InseeFr/Lunatic-Model) data format.
|
|
12
12
|
|
|
13
|
-
- [Storybook](https://inseefr.github.io/Lunatic/storybook),
|
|
14
|
-
- [Storybook v1](https://inseefr.github.io/Lunatic/storybook-v1),
|
|
15
|
-
- [Storybook Beta](https://inseefr.github.io/Lunatic/storybook-beta),
|
|
16
|
-
- [Documentation](https://inseefr.github.io/Lunatic/
|
|
13
|
+
- [Storybook](https://inseefr.github.io/Lunatic/storybook), branch `main`
|
|
14
|
+
- [Storybook v1](https://inseefr.github.io/Lunatic/storybook-v1), branch `v1-main`
|
|
15
|
+
- [Storybook Beta](https://inseefr.github.io/Lunatic/storybook-beta), branch `develop`
|
|
16
|
+
- [Documentation](https://inseefr.github.io/Lunatic/en/)
|
|
17
17
|
|
|
18
|
-
##
|
|
18
|
+
## Table of Contents
|
|
19
19
|
|
|
20
20
|
- [Lunatic](#lunatic)
|
|
21
|
-
- [
|
|
22
|
-
- [
|
|
23
|
-
- [
|
|
24
|
-
- [
|
|
25
|
-
- [
|
|
26
|
-
- [
|
|
27
|
-
- [
|
|
28
|
-
- [
|
|
29
|
-
- [
|
|
30
|
-
- [Convention
|
|
21
|
+
- [Table of Contents](#table-of-contents)
|
|
22
|
+
- [Usage](#usage)
|
|
23
|
+
- [The useLunatic Hook](#the-uselunatic-hook)
|
|
24
|
+
- [Components](#components)
|
|
25
|
+
- [Customization](#customization)
|
|
26
|
+
- [Internal Working](#internal-working)
|
|
27
|
+
- [General Functioning](#general-functioning)
|
|
28
|
+
- [Pages and Pager](#pages-and-pager)
|
|
29
|
+
- [VTL Execution](#vtl-execution)
|
|
30
|
+
- [Convention and Best Practices](#convention-and-best-practices)
|
|
31
31
|
|
|
32
|
-
##
|
|
32
|
+
## Usage
|
|
33
33
|
|
|
34
|
-
|
|
34
|
+
To get started, you need to install Lunatic:
|
|
35
35
|
|
|
36
36
|
```bash
|
|
37
|
-
yarn add @inseefr/lunatic
|
|
37
|
+
yarn add @inseefr/lunatic
|
|
38
38
|
```
|
|
39
39
|
|
|
40
|
-
###
|
|
40
|
+
### The useLunatic Hook
|
|
41
41
|
|
|
42
|
-
|
|
42
|
+
Next, wherever you want to display the form, you'll need to use the `useLunatic` hook.
|
|
43
43
|
|
|
44
44
|
```js
|
|
45
45
|
import { useLunatic } from '@inseefr/lunatic';
|
|
@@ -47,46 +47,46 @@ import { useLunatic } from '@inseefr/lunatic';
|
|
|
47
47
|
const obj = useLunatic(source, data, options);
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
-
|
|
53
|
-
-
|
|
54
|
-
-
|
|
55
|
-
- **features** (
|
|
56
|
-
- **preferences** (
|
|
57
|
-
- **onChange** (
|
|
58
|
-
- **management** (
|
|
59
|
-
- **initialPage** (
|
|
60
|
-
- **lastReachedPage** (
|
|
61
|
-
- **autoSuggesterLoading** (
|
|
62
|
-
- **suggesters
|
|
63
|
-
- **suggesterFetcher** (
|
|
64
|
-
- **activeControls** (
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
- `getComponents()`,
|
|
69
|
-
- `goPreviousPage()`,
|
|
70
|
-
- `goNextPage()`,
|
|
71
|
-
- `goToPage({ page: string })`,
|
|
72
|
-
- `getErrors()`,
|
|
73
|
-
- `getModalErrors()`,
|
|
74
|
-
- `getCurrentErrors()`,
|
|
75
|
-
- `pageTag`,
|
|
76
|
-
- `isFirstPage
|
|
77
|
-
- `isLastPage
|
|
78
|
-
- `pager`,
|
|
79
|
-
- `waiting`,
|
|
80
|
-
- `getData()`,
|
|
81
|
-
- `loopVariables`,
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
###
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
Lunatic
|
|
50
|
+
This hook takes three parameters:
|
|
51
|
+
|
|
52
|
+
- The **source**, which is a JSON representation of the [Lunatic-Model](https://github.com/InseeFr/Lunatic-Model).
|
|
53
|
+
- The **data**, which contains the initial questionnaire data (can be an empty object).
|
|
54
|
+
- An options object to configure the behavior.
|
|
55
|
+
- **features** (default `['VTL', 'MD']`), allows you to define supported functionalities.
|
|
56
|
+
- **preferences** (default `['COLLECTED']`).
|
|
57
|
+
- **onChange** (default `() => {}`), allows you to add logic to apply when an answer is changed (must be memoized as it's used as a dependency in an internal `useCallback`).
|
|
58
|
+
- **management** (default `false`): Not yet implemented, will allow managing multiple states of the same variable (used by recovery positions).
|
|
59
|
+
- **initialPage** (default `'1'`), allows you to define the starting page.
|
|
60
|
+
- **lastReachedPage** (default `undefined`), allows you to define the furthest reached page.
|
|
61
|
+
- **autoSuggesterLoading** (default `false`).
|
|
62
|
+
- **suggesters**.
|
|
63
|
+
- **suggesterFetcher** (default `fetch`), method used to retrieve suggester data.
|
|
64
|
+
- **activeControls** (default `false`), activates data controls.
|
|
65
|
+
|
|
66
|
+
And it returns an object that allows you to control the questionnaire:
|
|
67
|
+
|
|
68
|
+
- `getComponents()`, returns the components to display for the current page.
|
|
69
|
+
- `goPreviousPage()`, allows you to go to the previous page.
|
|
70
|
+
- `goNextPage()`, allows you to go to the next page.
|
|
71
|
+
- `goToPage({ page: string })`, allows you to go to an arbitrary page.
|
|
72
|
+
- `getErrors()`, returns the errors.
|
|
73
|
+
- `getModalErrors()`, returns the errors in modals.
|
|
74
|
+
- `getCurrentErrors()`, returns the errors for the current page.
|
|
75
|
+
- `pageTag`, a string containing the page number (e.g., 8.1).
|
|
76
|
+
- `isFirstPage`.
|
|
77
|
+
- `isLastPage`.
|
|
78
|
+
- `pager`, an object containing information related to the page.
|
|
79
|
+
- `waiting`, indicates waiting for information from a suggester.
|
|
80
|
+
- `getData()`, returns the collected data in the questionnaire.
|
|
81
|
+
- `loopVariables`, is an array containing the list of variables used for the current loop.
|
|
82
|
+
|
|
83
|
+
For more information on the types of this return, you can refer to the available types in the [source code](https://github.com/InseeFr/Lunatic/blob/v2-typescript/src/use-lunatic/type.ts#L64-L200). You can also find an example of using the hook in the [Storybook section](https://github.com/InseeFr/Lunatic/blob/v2-develop/src/stories/utils/orchestrator.js#L69-L93).
|
|
84
|
+
|
|
85
|
+
### Components
|
|
86
|
+
|
|
87
|
+
To display the questionnaire, start by retrieving the list of components to display using the `getComponents()` method returned by the hook.
|
|
88
|
+
|
|
89
|
+
Lunatic offers a library of pre-designed components to cover the different types of fields available in questionnaires.
|
|
90
90
|
|
|
91
91
|
```jsx
|
|
92
92
|
import * as lunatic from '@inseefr/lunatic';
|
|
@@ -100,23 +100,20 @@ function App({ source, data }) {
|
|
|
100
100
|
|
|
101
101
|
return (
|
|
102
102
|
<div className="container">
|
|
103
|
-
{components
|
|
104
|
-
const Component = lunatic[component.componentType];
|
|
105
|
-
return (
|
|
106
|
-
<Component key={component.id} {...component} errors={currentErrors} />
|
|
107
|
-
);
|
|
108
|
-
})}
|
|
103
|
+
<LunaticComponents components={components} />
|
|
109
104
|
<lunatic.Modal errors={modalErrors} goNext={goNextPage} />
|
|
110
105
|
</div>
|
|
111
106
|
);
|
|
112
107
|
}
|
|
113
108
|
```
|
|
114
109
|
|
|
115
|
-
|
|
110
|
+
All the components offered by Lunatic are available in the [src/components](https://github.com/InseeFr/Lunatic/blob/v2-develop/src/components/components.js) folder.
|
|
116
111
|
|
|
117
|
-
|
|
112
|
+
To activate the **autofocus**, you need to pass a key in the `autoFocusKey` property of `LunaticComponents`. As soon as this value changes, the first field is focused (a good solution is to pass the `pageTag` provided by `useLunatic`).
|
|
118
113
|
|
|
119
|
-
|
|
114
|
+
## Customization
|
|
115
|
+
|
|
116
|
+
By default, the components offered by Lunatic are quite simple with a minimal style. You can customize the fields with your own CSS, but for more complex cases, you can also replace the basic components using the `custom` property that you can pass when calling `useLunatic`.
|
|
120
117
|
|
|
121
118
|
```jsx
|
|
122
119
|
const custom = {
|
|
@@ -131,39 +128,59 @@ function App({ source, data }) {
|
|
|
131
128
|
}
|
|
132
129
|
```
|
|
133
130
|
|
|
134
|
-
##
|
|
131
|
+
## Internal Working
|
|
132
|
+
|
|
133
|
+
This section covers the internal working of the `useLunatic()` hook. The goal is to help understand how it operates.
|
|
134
|
+
|
|
135
|
+
### General Functioning
|
|
135
136
|
|
|
136
|
-
|
|
137
|
+
The hook is based on an [internal state](https://github.com/InseeFr/Lunatic/blob/v2-typescript/src/use-lunatic/type.ts#L64-L200) that is updated through a [reducer](https://reactjs.org/docs/hooks-reference.html#usereducer) system. The [actions](https://github.com/InseeFr/Lunatic/blob/v2-typescript/src/use-lunatic/actions.ts) affecting this state are limited:
|
|
137
138
|
|
|
138
|
-
|
|
139
|
+
- An action `'use-lunatic/on-init'` allows initialization of the state from the data received as a parameter of the hook.
|
|
140
|
+
- The actions `'use-lunatic/go-previous'`, `'use-lunatic/go-next'`, and `'use-lunatic/go-to-page'` are called during navigation using the methods returned by the hook.
|
|
141
|
+
- The action `use-lunatic/handle-change` is the most important action and is called whenever data is changed in the questionnaire.
|
|
139
142
|
|
|
140
|
-
|
|
143
|
+
All the [reducers corresponding to these actions are available here](https://github.com/InseeFr/Lunatic/blob/v2-develop/src/use-lunatic/reducer/reducer.js). Generally, they are broken down into several methods depending on the part of the state they modify.
|
|
141
144
|
|
|
142
|
-
|
|
143
|
-
- Les actions `'use-lunatic/go-previous'`, `'use-lunatic/go-next'` et `'use-lunatic/go-to-page'` sont appelées lors de la navigation à l'aide des méthodes renvoyées par le hook
|
|
144
|
-
- L'action `use-lunatic/handle-change` est l'action la plus importante qui est appelée dès lors qu'une donnée est changée dans le questionnaire.
|
|
145
|
+
### Pages and Pager
|
|
145
146
|
|
|
146
|
-
|
|
147
|
+
At initialization, the questionnaire scenario is modeled as an object which is stored in the state (in the `pages` property). This object is indexed by page number and contains the list of components to display for each page. Combined with the `pager` which contains the state of navigation, this property allows resolving the components to display.
|
|
147
148
|
|
|
148
|
-
###
|
|
149
|
+
### VTL Execution
|
|
149
150
|
|
|
150
|
-
|
|
151
|
+
Another important point of Lunatic is the execution of VTL expressions which allow making certain properties dynamic (labels, errors, etc.). This filling is done [when the state changes](https://github.com/InseeFr/Lunatic/blob/v2-develop/src/use-lunatic/commons/use-components-from-state.js).
|
|
151
152
|
|
|
152
|
-
|
|
153
|
+
To facilitate expression execution, an `executeExpression()` method is exposed in the Lunatic state. This method is accompanied by an `updateBindings()` method which allows updating internal values. This expression execution system uses a memoization system to not re-execute the same expression multiple times. When the `use-lunatic/handle-change` action is executed, the values ("bindings") are updated to memorize the values associated with the different VTL variables. Similarly, the values of calculated variables on which the modified variable depends are forgotten to refresh the value during the next execution.
|
|
153
154
|
|
|
154
|
-
|
|
155
|
+
## Convention and Best Practices
|
|
155
156
|
|
|
156
|
-
|
|
157
|
+
- Avoid "default" exports as it impairs readability during import.
|
|
158
|
+
- Comments in the code should be in English.
|
|
159
|
+
- Files containing JSX should use the .jsx (or .tsx) extension.
|
|
160
|
+
- Commits follow the specification [Conventional Commits](https://www.conventionalcommits.org/en/v1.0.0/).
|
|
161
|
+
- Pull Requests should be prefixed in the same convention as commits:
|
|
157
162
|
|
|
158
|
-
|
|
163
|
+
- `test(XXX?)`: XXX for adding tests.
|
|
164
|
+
- `feat(XXX?)`: XXX for adding new features.
|
|
165
|
+
- `fix(XXX?)`: XXX for bug fixes.
|
|
166
|
+
- `docs(XXX?)`: XXX for adding documentation.
|
|
167
|
+
- `refactor(XXX?)`: XXX for refactoring that doesn't change functionality.
|
|
168
|
+
- `build(XXX?)`: XXX for changes related to the build process, compilation scripts, etc.
|
|
169
|
+
- `style(XXX?)`: XXX for style modifications.
|
|
170
|
+
- `ci(XXX?)`: XXX for CI modification.
|
|
171
|
+
- `perf(XXX?)`: XXX for performance improvement.
|
|
172
|
+
- `revert(XXX?)`: XXX to revert a previous PR.
|
|
173
|
+
- `chore(XXX?)`: XXX for maintenance tasks or tasks that don't fall into other categories.
|
|
159
174
|
|
|
160
|
-
-
|
|
161
|
-
-
|
|
162
|
-
-
|
|
163
|
-
-
|
|
164
|
-
-
|
|
165
|
-
-
|
|
166
|
-
-
|
|
167
|
-
-
|
|
168
|
-
-
|
|
169
|
-
-
|
|
175
|
+
- Branches should be prefixed (following the same prefixes as Conventional Commits):
|
|
176
|
+
- `test/XXX`: for adding tests.
|
|
177
|
+
- `feat/XXX`: for adding new features.
|
|
178
|
+
- `fix/XXX`: for bug fixes.
|
|
179
|
+
- `docs/XXX`: for adding documentation.
|
|
180
|
+
- `refactor/XXX`: for refactoring that doesn't change functionality.
|
|
181
|
+
- `build/XXX`: for changes related to the build process, compilation scripts, etc.
|
|
182
|
+
- `style/XXX`: for changes related to code style.
|
|
183
|
+
- `ci/XXX`: for changes related to continuous integration (CI).
|
|
184
|
+
- `perf/XXX`: for performance improvements.
|
|
185
|
+
- `revert/XXX`: to revert a previous PR.
|
|
186
|
+
- `chore/XXX`: for maintenance tasks or tasks that don't fall into other categories.
|
|
@@ -1,37 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
3
|
Object.defineProperty(exports, "__esModule", {
|
|
5
4
|
value: true
|
|
6
5
|
});
|
|
7
6
|
exports["default"] = void 0;
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
7
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
8
|
+
var _dom = require("../../utils/dom");
|
|
10
9
|
var _isElement = require("../../utils/is-element");
|
|
11
10
|
var _commons = require("../commons");
|
|
12
11
|
require("./button.scss");
|
|
13
12
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
13
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
|
-
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
16
|
-
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
17
14
|
function Button(_ref) {
|
|
18
15
|
var children = _ref.children,
|
|
19
16
|
onClick = _ref.onClick,
|
|
20
17
|
disabled = _ref.disabled,
|
|
21
18
|
label = _ref.label,
|
|
22
|
-
className = _ref.className
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
if ((0, _isElement.isElement)(children)) return /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
19
|
+
className = _ref.className,
|
|
20
|
+
value = _ref.value,
|
|
21
|
+
_ref$type = _ref.type,
|
|
22
|
+
type = _ref$type === void 0 ? 'button' : _ref$type;
|
|
23
|
+
var handleClick = (0, _dom.prevent)(onClick);
|
|
24
|
+
if ((0, _isElement.isElement)(children) || value) return /*#__PURE__*/(0, _jsxRuntime.jsx)("button", {
|
|
29
25
|
disabled: disabled,
|
|
30
|
-
type:
|
|
26
|
+
type: type,
|
|
31
27
|
className: (0, _classnames["default"])('button-lunatic', className, {
|
|
32
28
|
disabled: disabled
|
|
33
29
|
}),
|
|
34
30
|
onClick: handleClick,
|
|
31
|
+
value: value,
|
|
35
32
|
children: children
|
|
36
33
|
});
|
|
37
34
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
@@ -41,7 +38,7 @@ function Button(_ref) {
|
|
|
41
38
|
className: (0, _classnames["default"])('button-lunatic', className, {
|
|
42
39
|
disabled: disabled
|
|
43
40
|
}),
|
|
44
|
-
value: label
|
|
41
|
+
value: label !== null && label !== void 0 ? label : children === null || children === void 0 ? void 0 : children.toString(),
|
|
45
42
|
onClick: handleClick
|
|
46
43
|
})
|
|
47
44
|
});
|
|
@@ -4,7 +4,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
var _react = _interopRequireDefault(require("react"));
|
|
8
7
|
var _checkboxGroupContent = _interopRequireDefault(require("./checkbox-group-content"));
|
|
9
8
|
var _commons = require("../../../commons");
|
|
10
9
|
require("./checkbox-group.scss");
|
|
@@ -8,7 +8,7 @@ exports.ComboBoxContent = ComboBoxContent;
|
|
|
8
8
|
exports["default"] = void 0;
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
10
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
11
|
-
var _keyboardKeyCodes = require("./
|
|
11
|
+
var _keyboardKeyCodes = require("./keyboard-key-codes");
|
|
12
12
|
var _index = require("../../index");
|
|
13
13
|
var _comboBoxContentBox = _interopRequireDefault(require("./combo-box-content-box"));
|
|
14
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -48,6 +48,7 @@ function ComboBoxContent(_ref) {
|
|
|
48
48
|
}, [onKeyDown]);
|
|
49
49
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_comboBoxContentBox["default"], {
|
|
50
50
|
classNamePrefix: classNamePrefix,
|
|
51
|
+
focused: focused,
|
|
51
52
|
children: /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
52
53
|
className: (0, _classnames["default"])("".concat(classNamePrefix !== null && classNamePrefix !== void 0 ? classNamePrefix : 'lunatic', "-combo-box-content"), {
|
|
53
54
|
focused: focused
|