@inseefr/lunatic 2.6.2 → 2.7.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.md +13 -3
- package/lib/components/button/lunatic-button.js +1 -2
- package/lib/components/checkbox/checkbox-boolean/html/checkbox-boolean.js +1 -2
- package/lib/components/checkbox/checkbox-boolean/lunatic-checkbox-boolean.js +1 -2
- package/lib/components/checkbox/checkbox-group/checkbox-group-content.js +1 -2
- package/lib/components/checkbox/checkbox-group/html/checkbox-group-content.js +1 -2
- package/lib/components/checkbox/checkbox-group/html/checkbox-group.js +1 -2
- package/lib/components/checkbox/checkbox-group/lunatic-checkbox-group.js +1 -2
- package/lib/components/checkbox/checkbox-one/html/checkbox-one.js +1 -2
- package/lib/components/checkbox/checkbox-one/lunatic-checkbox-one.js +1 -2
- package/lib/components/checkbox/commons/checkbox-option.js +1 -2
- package/lib/components/checkbox/commons/checkbox-option.spec.js +3 -3
- package/lib/components/checkbox/commons/getShortcutKey.js +2 -3
- package/lib/components/commons/components/combo-box/combo-box-container.js +1 -2
- package/lib/components/commons/components/combo-box/combo-box-content-box.js +1 -2
- package/lib/components/commons/components/combo-box/combo-box-content.js +5 -6
- package/lib/components/commons/components/combo-box/combo-box.js +4 -5
- package/lib/components/commons/components/combo-box/combo-box.stories.js +46 -49
- package/lib/components/commons/components/combo-box/keyboard-key-codes.js +2 -3
- package/lib/components/commons/components/combo-box/panel/combo-box-option.js +1 -2
- package/lib/components/commons/components/combo-box/panel/option-container.spec.js +3 -3
- package/lib/components/commons/components/combo-box/panel/panel-container.js +1 -2
- package/lib/components/commons/components/combo-box/panel/panel.spec.js +32 -17
- package/lib/components/commons/components/combo-box/selection/clear-button.js +1 -2
- package/lib/components/commons/components/combo-box/selection/clear-button.spec.js +61 -27
- package/lib/components/commons/components/combo-box/selection/combo-box-label-selection.js +1 -2
- package/lib/components/commons/components/combo-box/selection/input.js +4 -5
- package/lib/components/commons/components/combo-box/selection/label-selection.js +1 -2
- package/lib/components/commons/components/combo-box/selection/selection-container.js +1 -2
- package/lib/components/commons/components/combo-box/selection/selection.js +1 -1
- package/lib/components/commons/components/description.js +2 -4
- package/lib/components/commons/components/dragger/dragger.js +5 -6
- package/lib/components/commons/components/errors/errors.js +2 -3
- package/lib/components/commons/components/fab/fab.js +1 -2
- package/lib/components/commons/components/fab/fab.spec.js +59 -34
- package/lib/components/commons/components/field-container/field-container.js +1 -2
- package/lib/components/commons/components/fieldset.js +1 -2
- package/lib/components/commons/components/html-table/table.js +1 -2
- package/lib/components/commons/components/html-table/tbody.js +1 -2
- package/lib/components/commons/components/html-table/td.js +1 -2
- package/lib/components/commons/components/html-table/th.js +1 -2
- package/lib/components/commons/components/html-table/th.spec.js +3 -3
- package/lib/components/commons/components/html-table/thead.js +1 -2
- package/lib/components/commons/components/html-table/thead.spec.js +3 -3
- package/lib/components/commons/components/html-table/tr.js +1 -2
- package/lib/components/commons/components/is-network/is-network.js +7 -8
- package/lib/components/commons/components/is-network/use-online-status.js +1 -2
- package/lib/components/commons/components/label/label.js +1 -2
- package/lib/components/commons/components/lunatic-component-with-label.js +4 -5
- package/lib/components/commons/components/lunatic-component-without-label.js +4 -5
- package/lib/components/commons/components/md-label/link.js +1 -2
- package/lib/components/commons/components/md-label/md-label.js +4 -5
- package/lib/components/commons/components/missing/missing.js +5 -7
- package/lib/components/commons/components/nothing-to-display.js +1 -2
- package/lib/components/commons/components/orchestrated-component.js +6 -7
- package/lib/components/commons/components/variable-status/variable-status.js +5 -6
- package/lib/components/commons/create-customizable-field.js +4 -5
- package/lib/components/commons/icons/radio-checked-icon.js +1 -2
- package/lib/components/commons/index.js +3 -3
- package/lib/components/commons/safety-label.js +2 -3
- package/lib/components/commons/use-document-add-event-listener.js +1 -2
- package/lib/components/commons/use-on-handle-change.js +1 -2
- package/lib/components/commons/use-options-keydown.js +1 -2
- package/lib/components/component-set/html/component-set-wrapper.js +2 -3
- package/lib/components/component-set/html/component-set.js +1 -2
- package/lib/components/component-set/lunatic-component-set.js +3 -3
- package/lib/components/datepicker/html/datepicker-container.js +1 -2
- package/lib/components/datepicker/html/datepicker-input.js +1 -2
- package/lib/components/datepicker/html/datepicker.js +1 -2
- package/lib/components/datepicker/lunatic-datepicker.js +1 -2
- package/lib/components/declarations/declaration.js +1 -2
- package/lib/components/declarations/declarations-after-text.js +6 -7
- package/lib/components/declarations/declarations-before-text.js +6 -7
- package/lib/components/declarations/declarations-detachable.js +6 -7
- package/lib/components/declarations/declarations.js +2 -4
- package/lib/components/declarations/index.js +3 -3
- package/lib/components/dropdown/html/dropdown-simple/dropdown-simple.js +1 -2
- package/lib/components/dropdown/html/dropdown-simple/simple-label-renderer.js +1 -2
- package/lib/components/dropdown/html/dropdown-simple/simple-option-renderer.js +1 -2
- package/lib/components/dropdown/html/dropdown-writable/dropdown-writable.js +2 -3
- package/lib/components/dropdown/html/dropdown-writable/filter-tools/filter-options.js +1 -2
- package/lib/components/dropdown/html/dropdown-writable/filter-tools/get-label.js +2 -3
- package/lib/components/dropdown/html/dropdown-writable/filter-tools/letters-matching.js +1 -2
- package/lib/components/dropdown/html/dropdown-writable/filter-tools/match.js +1 -2
- package/lib/components/dropdown/html/dropdown-writable/filter-tools/prepare-prefix.js +1 -2
- package/lib/components/dropdown/html/dropdown-writable/writable-label-renderer.js +1 -2
- package/lib/components/dropdown/html/dropdown-writable/writable-option-renderer.js +5 -6
- package/lib/components/dropdown/html/dropdown.js +1 -2
- package/lib/components/dropdown/lunatic-dropdown.js +1 -2
- package/lib/components/duration/duration.js +1 -2
- package/lib/components/duration/durationInput.js +5 -6
- package/lib/components/duration/durationUtils.js +3 -5
- package/lib/components/duration/formatDuration.js +2 -3
- package/lib/components/duration/getDurationFromValue.js +1 -2
- package/lib/components/filter-description/component.js +1 -2
- package/lib/components/index.js +4 -4
- package/lib/components/input/html/input.js +1 -2
- package/lib/components/input/lunatic-input.js +1 -2
- package/lib/components/input-number/html/input-number-thousand.js +2 -3
- package/lib/components/input-number/html/input-number.js +1 -2
- package/lib/components/input-number/lunatic-input-number.js +1 -2
- package/lib/components/loop/block-for-loop.js +12 -17
- package/lib/components/loop/loop.js +3 -3
- package/lib/components/loop/roster-for-loop/roster-for-loop.js +32 -41
- package/lib/components/lunatic-components.js +21 -10
- package/lib/components/modal/html/modal.js +1 -2
- package/lib/components/modal/lunatic-modal.js +2 -3
- package/lib/components/modal-controls/close-or-skip.js +1 -2
- package/lib/components/modal-controls/modal-container.js +1 -2
- package/lib/components/modal-controls/modal-controls.js +5 -6
- package/lib/components/pairwise-links/pairwise-links.js +28 -32
- package/lib/components/question-explication/html/question-explication.js +2 -3
- package/lib/components/question-explication/lunatic-question-explication.js +1 -2
- package/lib/components/question-explication/question-explication.spec.js +4 -4
- package/lib/components/questions/question-context.js +1 -2
- package/lib/components/questions/question-information.js +1 -2
- package/lib/components/radio/html/radio-group-content.js +1 -2
- package/lib/components/radio/html/radio-group.js +1 -2
- package/lib/components/radio/html/radio-option.js +2 -3
- package/lib/components/radio/lunatic-radio-group.js +1 -2
- package/lib/components/roundabout/components/roundabout-container.js +1 -2
- package/lib/components/roundabout/components/roundabout-it-button.js +4 -5
- package/lib/components/roundabout/components/roundabout-it-container.js +1 -2
- package/lib/components/roundabout/components/roundabout-it-title.js +1 -2
- package/lib/components/roundabout/components/roundabout-label.js +1 -2
- package/lib/components/roundabout/components/roundabout-pending.js +1 -2
- package/lib/components/roundabout/lunatic-roundabout.js +1 -2
- package/lib/components/roundabout/redirect.js +4 -5
- package/lib/components/roundabout/roundabout.js +1 -2
- package/lib/components/sequence/html/sequence.js +1 -2
- package/lib/components/sequence/lunatic-sequence.js +1 -2
- package/lib/components/sequence/sequence.spec.js +3 -3
- package/lib/components/subsequence/subsequence.js +1 -2
- package/lib/components/subsequence/subsequence.spec.js +3 -3
- package/lib/components/suggester/find-best-label/find-best-label.js +1 -2
- package/lib/components/suggester/html/notification.js +1 -2
- package/lib/components/suggester/html/suggester.js +5 -6
- package/lib/components/suggester/idb-suggester/check-store.js +4 -5
- package/lib/components/suggester/idb-suggester/idb-suggester.js +1 -1
- package/lib/components/suggester/idb-suggester/suggester-notification.js +1 -2
- package/lib/components/suggester/idb-suggester/suggester-status.js +1 -2
- package/lib/components/suggester/lunatic-suggester.js +1 -2
- package/lib/components/suggester/searching/create-searching.js +9 -6
- package/lib/components/suggester-loader-widget/loader-row.js +2 -3
- package/lib/components/suggester-loader-widget/loader.js +4 -5
- package/lib/components/suggester-loader-widget/progress.js +1 -2
- package/lib/components/suggester-loader-widget/tools/action-tool.js +1 -2
- package/lib/components/suggester-loader-widget/tools/tools.js +1 -2
- package/lib/components/suggester-loader-widget/widget-container.js +1 -2
- package/lib/components/suggester-loader-widget/widget.js +7 -8
- package/lib/components/summary/html/summary-responses.js +1 -2
- package/lib/components/summary/html/summary-title.js +1 -2
- package/lib/components/switch/html/switch.js +1 -2
- package/lib/components/switch/lunatic-switch.js +1 -2
- package/lib/components/table/lunatic-table.js +23 -15
- package/lib/components/table/{header.js → table-header.js} +3 -5
- package/lib/components/textarea/html/textarea.js +1 -2
- package/lib/components/textarea/lunatic-textarea.js +1 -2
- package/lib/constants/component-types.js +1 -2
- package/lib/constants/declarations.js +10 -18
- package/lib/constants/event-types.js +10 -20
- package/lib/constants/supported-preferences.js +4 -5
- package/lib/constants/value-types.js +5 -10
- package/lib/constants/variable-types.js +3 -5
- package/lib/hooks/use-track-changes.js +50 -0
- package/lib/i18n/build-dictionary.js +8 -11
- package/lib/i18n/dictionary.js +1 -2
- package/lib/i18n/index.js +7 -9
- package/lib/i18n/inputNumberProps.js +2 -4
- package/lib/src/components/commons/components/combo-box/combo-box.stories.d.ts +6 -57
- package/lib/src/components/index.d.ts +2 -2
- package/lib/src/components/loop/block-for-loop.d.ts +3 -4
- package/lib/src/components/loop/roster-for-loop/roster-for-loop.d.ts +3 -4
- package/lib/src/components/lunatic-components.d.ts +5 -3
- package/lib/src/components/pairwise-links/pairwise-links.d.ts +1 -2
- package/lib/src/components/table/lunatic-table.d.ts +1 -1
- package/lib/src/components/table/{header.d.ts → table-header.d.ts} +2 -2
- package/lib/src/components/type.d.ts +5 -6
- package/lib/src/hooks/use-track-changes.d.ts +9 -0
- package/lib/src/use-lunatic/actions.d.ts +3 -16
- package/lib/src/use-lunatic/commons/compile-controls.d.ts +3 -2
- package/lib/src/use-lunatic/commons/component.d.ts +22 -0
- package/lib/src/use-lunatic/commons/fill-components/fill-component-value.d.ts +2 -3
- package/lib/src/use-lunatic/commons/fill-components/fill-components.d.ts +6 -0
- package/lib/src/use-lunatic/commons/fill-components/fill-from-state.d.ts +107 -122
- package/lib/src/use-lunatic/commons/fill-components/fill-iterations.d.ts +112 -0
- package/lib/src/use-lunatic/commons/fill-components/fill-specific-expression.d.ts +53 -89
- package/lib/src/use-lunatic/commons/get-compatible-vtl-expression.d.ts +1 -0
- package/lib/src/use-lunatic/commons/index.d.ts +0 -3
- package/lib/src/use-lunatic/commons/variables/behaviours/cleaning-behaviour.d.ts +7 -0
- package/lib/src/use-lunatic/commons/variables/behaviours/missing-behaviour.d.ts +7 -0
- package/lib/src/use-lunatic/commons/variables/behaviours/resizing-behaviour.d.ts +7 -0
- package/lib/src/use-lunatic/commons/variables/get-questionnaire-data.d.ts +4 -0
- package/lib/src/use-lunatic/commons/variables/lunatic-variables-store.d.ts +77 -0
- package/lib/src/use-lunatic/reducer/overview/overview-on-init.d.ts +10 -8
- package/lib/src/use-lunatic/reducer/reduce-handle-change.d.ts +6 -0
- package/lib/src/use-lunatic/reducer/reduce-on-init.d.ts +1 -12
- package/lib/src/use-lunatic/type-source.d.ts +7 -21
- package/lib/src/use-lunatic/type.d.ts +13 -11
- package/lib/src/use-lunatic/use-lunatic.d.ts +33 -56
- package/lib/src/utils/array.d.ts +6 -1
- package/lib/src/utils/env.d.ts +1 -0
- package/lib/src/utils/number.d.ts +4 -0
- package/lib/src/utils/variables.d.ts +5 -0
- package/lib/src/utils/vtl.d.ts +14 -0
- package/lib/stories/Introduction.stories.mdx +2 -4
- package/lib/stories/checkbox-boolean/checkboxBoolean.stories.js +5 -7
- package/lib/stories/checkbox-group/checkbox-group.stories.js +28 -11
- package/lib/stories/checkbox-group/source.json +343 -27
- package/lib/stories/checkbox-one/checkboxOne.stories.js +5 -7
- package/lib/stories/component-set/component-set.stories.js +7 -11
- package/lib/stories/custom-mui/checkbox-boolean-mui.js +4 -5
- package/lib/stories/custom-mui/checkbox-group-mui.js +4 -5
- package/lib/stories/custom-mui/checkbox-one-mui.js +1 -2
- package/lib/stories/custom-mui/input-mui.js +4 -5
- package/lib/stories/custom-mui/input-number-mui.js +4 -5
- package/lib/stories/custom-mui/radio-mui.js +4 -5
- package/lib/stories/custom-mui/suggester-mui/suggester-mui.js +5 -6
- package/lib/stories/custom-mui/switch-mui.js +4 -5
- package/lib/stories/custom-mui/table-mui.js +1 -2
- package/lib/stories/custom-mui/tbody-mui.js +1 -2
- package/lib/stories/custom-mui/td-mui.js +1 -2
- package/lib/stories/custom-mui/textarea-mui.js +4 -5
- package/lib/stories/custom-mui/th-mui.js +1 -2
- package/lib/stories/custom-mui/thead-mui.js +1 -2
- package/lib/stories/custom-mui/tr-mui.js +1 -2
- package/lib/stories/date-picker/datepicker.stories.js +5 -7
- package/lib/stories/declaration/input.stories.js +5 -7
- package/lib/stories/disabled/disabled.stories.js +5 -7
- package/lib/stories/dropdown/dropdown.stories.js +5 -7
- package/lib/stories/duration/duration.stories.js +6 -9
- package/lib/stories/filter-description/filter-description.stories.js +6 -9
- package/lib/stories/input/input.stories.js +6 -9
- package/lib/stories/input-number/input-number.stories.js +7 -11
- package/lib/stories/loop/block-for-loop.stories.js +7 -11
- package/lib/stories/loop/paginated-loop.stories.js +5 -7
- package/lib/stories/loop/roster-for-loop.stories.js +8 -12
- package/lib/stories/modal/modal.stories.js +5 -7
- package/lib/stories/overview/overview.stories.js +5 -7
- package/lib/stories/pairwise/pairwise-links.stories.js +8 -12
- package/lib/stories/paste-questionnaire/test.stories.js +5 -7
- package/lib/stories/question-explication/question-explication.stories.js +5 -7
- package/lib/stories/questionnaires/logement/logement.stories.js +7 -11
- package/lib/stories/questionnaires/recensement/recensement.stories.js +5 -7
- package/lib/stories/questionnaires/rp/rp.stories.js +5 -7
- package/lib/stories/questionnaires/simpsons/simpsons.stories.js +8 -12
- package/lib/stories/questionnaires-test/controls/controls-externes.stories.js +5 -7
- package/lib/stories/questionnaires-test/controls/controls.stories.js +9 -15
- package/lib/stories/questionnaires-test/test.stories.js +9 -15
- package/lib/stories/questionnaires2023/bySequence/ticWeb.stories.js +5 -7
- package/lib/stories/questionnaires2023/famille/famille.stories.js +5 -7
- package/lib/stories/questionnaires2023/simpsons/simpsons.stories.js +5 -7
- package/lib/stories/questionnaires2023/ticTel/ticWeb.stories.js +5 -7
- package/lib/stories/questionnaires2023/ticWeb/ticWeb.stories.js +5 -7
- package/lib/stories/radio/radio.stories.js +5 -7
- package/lib/stories/resizing-questionnaire/test.stories.js +5 -7
- package/lib/stories/roundabout/roundabout.stories.js +6 -9
- package/lib/stories/sequence/sequence.stories.js +5 -7
- package/lib/stories/suggester/suggester-workers.stories.js +7 -9
- package/lib/stories/suggester/suggester.stories.js +8 -12
- package/lib/stories/summary/summary.stories.js +5 -7
- package/lib/stories/switch/switch.stories.js +7 -9
- package/lib/stories/table/table.stories.js +10 -15
- package/lib/stories/textarea/textarea.stories.js +5 -7
- package/lib/stories/utils/default-arg-types.js +4 -5
- package/lib/stories/utils/options.js +5 -9
- package/lib/stories/utils/orchestrator.js +10 -10
- package/lib/stories/utils/overview.js +2 -3
- package/lib/stories/utils/waiting/waiting.js +1 -2
- package/lib/test.d.js +3 -0
- package/lib/use-lunatic/actions.js +10 -18
- package/lib/use-lunatic/commons/check-loops.js +5 -6
- package/lib/use-lunatic/commons/compile-controls.js +6 -8
- package/lib/use-lunatic/commons/component.js +22 -0
- package/lib/use-lunatic/commons/compose.js +1 -2
- package/lib/use-lunatic/commons/create-map-pages.js +4 -5
- package/lib/use-lunatic/commons/execute-condition-filter.js +2 -11
- package/lib/use-lunatic/commons/fill-components/fill-component-expressions.js +6 -8
- package/lib/use-lunatic/commons/fill-components/fill-component-value.js +24 -10
- package/lib/use-lunatic/commons/fill-components/fill-components.js +5 -5
- package/lib/use-lunatic/commons/fill-components/fill-from-state.js +4 -5
- package/lib/use-lunatic/commons/fill-components/fill-iterations.js +45 -0
- package/lib/use-lunatic/commons/fill-components/fill-management.js +4 -5
- package/lib/use-lunatic/commons/fill-components/fill-missing-response.js +10 -18
- package/lib/use-lunatic/commons/fill-components/fill-pagination.js +4 -5
- package/lib/use-lunatic/commons/fill-components/fill-specific-expression.js +63 -11
- package/lib/use-lunatic/commons/get-compatible-vtl-expression.js +3 -3
- package/lib/use-lunatic/commons/get-components-from-state.js +1 -2
- package/lib/use-lunatic/commons/get-errors-without-empty-value.js +2 -3
- package/lib/use-lunatic/commons/getOverview.js +3 -4
- package/lib/use-lunatic/commons/index.js +0 -21
- package/lib/use-lunatic/commons/is-First-last-page.js +1 -2
- package/lib/use-lunatic/commons/is-paginated-loop.js +1 -2
- package/lib/use-lunatic/commons/page-navigation.js +4 -4
- package/lib/use-lunatic/commons/page-navigation.spec.js +3 -3
- package/lib/use-lunatic/commons/page-tag.js +3 -3
- package/lib/use-lunatic/commons/use-components-from-state.js +1 -2
- package/lib/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js +39 -0
- package/lib/use-lunatic/commons/variables/behaviours/missing-behaviour.js +47 -0
- package/lib/use-lunatic/commons/variables/behaviours/resizing-behaviour.js +78 -0
- package/lib/use-lunatic/commons/variables/get-questionnaire-data.js +65 -0
- package/lib/use-lunatic/commons/variables/lunatic-variables-store.js +329 -0
- package/lib/use-lunatic/commons/variables/lunatic-variables-store.spec.js +216 -0
- package/lib/use-lunatic/initial-state.js +6 -4
- package/lib/use-lunatic/lunatic-context.js +3 -6
- package/lib/use-lunatic/reducer/commons/auto-explore-loop.js +3 -3
- package/lib/use-lunatic/reducer/commons/is-loop-component.js +2 -3
- package/lib/use-lunatic/reducer/commons/resize-array-variable.js +1 -2
- package/lib/use-lunatic/reducer/commons/validate-condition-filter.js +1 -1
- package/lib/use-lunatic/reducer/overview/overview-on-change.js +6 -7
- package/lib/use-lunatic/reducer/overview/overview-on-init.js +5 -5
- package/lib/use-lunatic/reducer/reduce-go-next-page.js +5 -6
- package/lib/use-lunatic/reducer/reduce-go-previous-page.js +4 -5
- package/lib/use-lunatic/reducer/reduce-go-to-page.js +4 -5
- package/lib/use-lunatic/reducer/reduce-handle-change.js +29 -0
- package/lib/use-lunatic/reducer/reduce-on-init.js +93 -186
- package/lib/use-lunatic/reducer/reduce-on-set-waiting.js +4 -5
- package/lib/use-lunatic/reducer/reduce-update-state.js +3 -3
- package/lib/use-lunatic/reducer/reducer.js +3 -4
- package/lib/use-lunatic/reducer/resolve-component-controls/resolve-simple-control.js +2 -4
- package/lib/use-lunatic/type-source.js +4 -7
- package/lib/use-lunatic/use-lunatic.js +23 -20
- package/lib/use-lunatic/use-lunatic.test.js +134 -5
- package/lib/use-lunatic/use-suggesters.js +6 -7
- package/lib/utils/array.js +57 -6
- package/lib/utils/array.spec.js +30 -0
- package/lib/utils/constants/alphabet.js +1 -2
- package/lib/utils/constants/features.js +3 -6
- package/lib/utils/constants/links.js +2 -4
- package/lib/utils/constants/missing.js +2 -4
- package/lib/utils/constants/variable-status.js +5 -10
- package/lib/utils/constants/variable-types.js +1 -2
- package/lib/utils/env.js +10 -0
- package/lib/utils/function.js +1 -2
- package/lib/utils/get-component-value.js +3 -9
- package/lib/utils/idb-tools/clear-store.js +3 -4
- package/lib/utils/idb-tools/create-db-opener.js +1 -2
- package/lib/utils/idb-tools/create-open-db.js +1 -2
- package/lib/utils/idb-tools/get-entity.js +1 -2
- package/lib/utils/idb-tools/get-idb.js +1 -2
- package/lib/utils/idb-tools/idb-bulk-insert.js +5 -7
- package/lib/utils/idb-tools/index.js +3 -3
- package/lib/utils/idb-tools/insert-entity.js +1 -2
- package/lib/utils/idb-tools/open-db.js +3 -4
- package/lib/utils/idb-tools/open-or-create-db.js +2 -3
- package/lib/utils/is-object.js +1 -1
- package/lib/utils/logger.js +3 -4
- package/lib/utils/number.js +14 -2
- package/lib/utils/object.js +1 -1
- package/lib/utils/store-tools/clear-store-data.js +3 -4
- package/lib/utils/store-tools/clear-store-info.js +3 -4
- package/lib/utils/store-tools/constantes.js +7 -14
- package/lib/utils/store-tools/create/create.js +3 -4
- package/lib/utils/store-tools/create/update-store-info.js +1 -2
- package/lib/utils/store-tools/get-store-count.js +1 -2
- package/lib/utils/store-tools/index.js +3 -3
- package/lib/utils/store-tools/initStore.js +2 -2
- package/lib/utils/store-tools/open-or-create-store.js +1 -2
- package/lib/utils/store-tools/use-store-index.js +4 -5
- package/lib/utils/suggester-workers/append-to-index/append.js +3 -4
- package/lib/utils/suggester-workers/append-to-index/append.worker.js +1 -2
- package/lib/utils/suggester-workers/append-to-index/prepare-entities.js +5 -6
- package/lib/utils/suggester-workers/append-to-index/store-messages.js +4 -5
- package/lib/utils/suggester-workers/commons-tokenizer/create-entity-tokenizer.js +4 -5
- package/lib/utils/suggester-workers/commons-tokenizer/create-fields-tokenizer.js +5 -6
- package/lib/utils/suggester-workers/commons-tokenizer/create-filter-stop-words.js +4 -5
- package/lib/utils/suggester-workers/commons-tokenizer/filters/compose-filters.js +1 -2
- package/lib/utils/suggester-workers/commons-tokenizer/filters/create-filter-stop-words.js +4 -5
- package/lib/utils/suggester-workers/commons-tokenizer/filters/filter-accents.js +1 -2
- package/lib/utils/suggester-workers/commons-tokenizer/filters/filter-double.js +1 -2
- package/lib/utils/suggester-workers/commons-tokenizer/filters/filter-length.js +1 -2
- package/lib/utils/suggester-workers/commons-tokenizer/filters/filter-stemmer.js +1 -2
- package/lib/utils/suggester-workers/commons-tokenizer/filters/filter-synonyms.js +4 -5
- package/lib/utils/suggester-workers/commons-tokenizer/filters/filter-to-lower.js +1 -2
- package/lib/utils/suggester-workers/commons-tokenizer/filters/stop-words.js +1 -2
- package/lib/utils/suggester-workers/commons-tokenizer/get-regexp-from-pattern.js +1 -2
- package/lib/utils/suggester-workers/commons-tokenizer/get-stemmer.js +1 -2
- package/lib/utils/suggester-workers/commons-tokenizer/prepare-string-indexation.js +1 -2
- package/lib/utils/suggester-workers/commons-tokenizer/soft-tokenizer.js +1 -2
- package/lib/utils/suggester-workers/create-worker-ts.js +2 -3
- package/lib/utils/suggester-workers/create-worker.js +2 -3
- package/lib/utils/suggester-workers/find-best-label/find-best-label.js +5 -6
- package/lib/utils/suggester-workers/find-best-label/tokenize.js +3 -4
- package/lib/utils/suggester-workers/searching/compute-score.js +4 -5
- package/lib/utils/suggester-workers/searching/get-db.js +3 -4
- package/lib/utils/suggester-workers/searching/order/create-alphanumeric-orderer.js +1 -2
- package/lib/utils/suggester-workers/searching/order/index.js +1 -2
- package/lib/utils/suggester-workers/searching/query-parser/query-parser-soft.js +1 -2
- package/lib/utils/suggester-workers/searching/query-parser/query-parser-tokenized.js +1 -2
- package/lib/utils/suggester-workers/searching/resolve-query-parser.js +3 -4
- package/lib/utils/suggester-workers/searching/search-in-index.js +1 -2
- package/lib/utils/suggester-workers/searching/searching.js +5 -6
- package/lib/utils/variables.js +37 -0
- package/lib/utils/vtl.js +100 -0
- package/package.json +28 -16
- package/lib/components/loop/utils/get-initial-nb-rows.js +0 -17
- package/lib/components/pairwise-links/index.js +0 -13
- package/lib/components/pairwise-links/orchestrator.js +0 -71
- package/lib/components/pairwise-links/row.js +0 -74
- package/lib/components/table/cell.js +0 -89
- package/lib/components/table/index.js +0 -13
- package/lib/components/table/row.js +0 -40
- package/lib/components/table/table-orchestrator.js +0 -35
- package/lib/src/components/loop/utils/get-initial-nb-rows.d.ts +0 -4
- package/lib/src/components/pairwise-links/index.d.ts +0 -1
- package/lib/src/components/pairwise-links/orchestrator.d.ts +0 -6
- package/lib/src/components/pairwise-links/row.d.ts +0 -7
- package/lib/src/components/table/cell.d.ts +0 -19
- package/lib/src/components/table/index.d.ts +0 -1
- package/lib/src/components/table/row.d.ts +0 -18
- package/lib/src/components/table/table-orchestrator.d.ts +0 -4
- package/lib/src/use-lunatic/commons/calculated-variables.d.ts +0 -8
- package/lib/src/use-lunatic/commons/execute-expression/create-execute-expression.d.ts +0 -9
- package/lib/src/use-lunatic/commons/execute-expression/create-memoizer.d.ts +0 -8
- package/lib/src/use-lunatic/commons/execute-expression/create-refresh-calculated.d.ts +0 -24
- package/lib/src/use-lunatic/commons/execute-expression/execute-expression.d.ts +0 -11
- package/lib/src/use-lunatic/commons/execute-expression/get-expressions-variables.d.ts +0 -7
- package/lib/src/use-lunatic/commons/execute-expression/get-expressions-variables.spec.d.ts +0 -1
- package/lib/src/use-lunatic/commons/execute-expression/get-safety-expression.d.ts +0 -6
- package/lib/src/use-lunatic/commons/execute-expression/index.d.ts +0 -1
- package/lib/src/use-lunatic/commons/get-component-value/get-component-value.d.ts +0 -6
- package/lib/src/use-lunatic/commons/get-component-value/index.d.ts +0 -1
- package/lib/src/use-lunatic/commons/get-data.d.ts +0 -26
- package/lib/src/use-lunatic/reducer/reduce-handle-change/index.d.ts +0 -1
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-cleaning.d.ts +0 -7
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-cleaning.spec.d.ts +0 -1
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-handle-change.d.ts +0 -4
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-links-variable.d.ts +0 -15
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-missing.d.ts +0 -7
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-resizing.d.ts +0 -4
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-variables-array.d.ts +0 -14
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-variables-simple.d.ts +0 -9
- package/lib/src/use-lunatic/reducer/reduce-on-init.spec.d.ts +0 -1
- package/lib/src/utils/vtl/dataset-builder.d.ts +0 -5
- package/lib/src/utils/vtl/index.d.ts +0 -1
- package/lib/stories/checkboxGroup/checkboxGroup.stories.js +0 -59
- package/lib/stories/checkboxGroup/source.json +0 -402
- package/lib/use-lunatic/commons/calculated-variables.js +0 -104
- package/lib/use-lunatic/commons/execute-expression/create-execute-expression.js +0 -233
- package/lib/use-lunatic/commons/execute-expression/create-execute-expression.spec.js +0 -155
- package/lib/use-lunatic/commons/execute-expression/create-memoizer.js +0 -63
- package/lib/use-lunatic/commons/execute-expression/create-refresh-calculated.js +0 -149
- package/lib/use-lunatic/commons/execute-expression/create-refresh-calculated.spec.js +0 -130
- package/lib/use-lunatic/commons/execute-expression/execute-expression.js +0 -90
- package/lib/use-lunatic/commons/execute-expression/execute-expression.spec.js +0 -38
- package/lib/use-lunatic/commons/execute-expression/get-expressions-variables.js +0 -40
- package/lib/use-lunatic/commons/execute-expression/get-expressions-variables.spec.js +0 -31
- package/lib/use-lunatic/commons/execute-expression/get-safety-expression.js +0 -35
- package/lib/use-lunatic/commons/execute-expression/index.js +0 -13
- package/lib/use-lunatic/commons/get-component-value/get-component-value.js +0 -174
- package/lib/use-lunatic/commons/get-component-value/index.js +0 -13
- package/lib/use-lunatic/commons/get-data.js +0 -80
- package/lib/use-lunatic/reducer/reduce-handle-change/__mocks__/source-cleaning-loop.json +0 -792
- package/lib/use-lunatic/reducer/reduce-handle-change/index.js +0 -13
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-cleaning.js +0 -72
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-cleaning.spec.js +0 -46
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-handle-change.js +0 -115
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-links-variable.js +0 -89
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-missing.js +0 -88
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-resizing.js +0 -110
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-variables-array.js +0 -44
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-variables-simple.js +0 -28
- package/lib/use-lunatic/reducer/reduce-on-init.spec.js +0 -17
- package/lib/utils/vtl/dataset-builder.js +0 -27
- package/lib/utils/vtl/index.js +0 -13
- /package/lib/src/use-lunatic/commons/{execute-expression/create-refresh-calculated.spec.d.ts → variables/lunatic-variables-store.spec.d.ts} +0 -0
- /package/lib/src/{use-lunatic/commons/execute-expression/execute-expression.spec.d.ts → utils/array.spec.d.ts} +0 -0
- /package/lib/stories/{checkboxGroup → checkbox-group}/sourceComponentset.json +0 -0
- /package/lib/stories/{checkboxGroup → checkbox-group}/sourceLoop.json +0 -0
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _vitest = require("vitest");
|
|
4
|
-
var _createRefreshCalculated = _interopRequireDefault(require("./create-refresh-calculated"));
|
|
5
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
6
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
7
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
|
-
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
9
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
10
|
-
function _construct(Parent, args, Class) { if (_isNativeReflectConstruct()) { _construct = Reflect.construct.bind(); } else { _construct = function _construct(Parent, args, Class) { var a = [null]; a.push.apply(a, args); var Constructor = Function.bind.apply(Parent, a); var instance = new Constructor(); if (Class) _setPrototypeOf(instance, Class.prototype); return instance; }; } return _construct.apply(null, arguments); }
|
|
11
|
-
function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
|
|
12
|
-
function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
|
|
13
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
14
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
15
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
16
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
17
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
18
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
19
|
-
var variables = {
|
|
20
|
-
AGE: {
|
|
21
|
-
type: 'COLLECTED',
|
|
22
|
-
value: null,
|
|
23
|
-
variable: {
|
|
24
|
-
variableType: 'COLLECTED',
|
|
25
|
-
values: {
|
|
26
|
-
PREVIOUS: null,
|
|
27
|
-
COLLECTED: null,
|
|
28
|
-
FORCED: null,
|
|
29
|
-
EDITED: null,
|
|
30
|
-
INPUTED: null
|
|
31
|
-
},
|
|
32
|
-
name: 'AGE'
|
|
33
|
-
}
|
|
34
|
-
},
|
|
35
|
-
COUNT_AGES: {
|
|
36
|
-
type: 'CALCULATED',
|
|
37
|
-
value: null,
|
|
38
|
-
variable: {
|
|
39
|
-
variableType: 'CALCULATED',
|
|
40
|
-
name: 'COUNT_AGES',
|
|
41
|
-
expression: {
|
|
42
|
-
value: 'AGE.length',
|
|
43
|
-
type: 'VTL'
|
|
44
|
-
},
|
|
45
|
-
bindingDependencies: ['AGE'],
|
|
46
|
-
inFilter: 'true'
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
AGE_ONE_PLUS: {
|
|
50
|
-
type: 'CALCULATED',
|
|
51
|
-
value: null,
|
|
52
|
-
variable: {
|
|
53
|
-
variableType: 'CALCULATED',
|
|
54
|
-
name: 'AGE_ONE_PLUS',
|
|
55
|
-
expression: {
|
|
56
|
-
value: 'AGE + 1',
|
|
57
|
-
type: 'VTL'
|
|
58
|
-
},
|
|
59
|
-
bindingDependencies: ['AGE'],
|
|
60
|
-
inFilter: 'true',
|
|
61
|
-
shapeFrom: 'AGE'
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
};
|
|
65
|
-
|
|
66
|
-
/**
|
|
67
|
-
* Execute JavaScript expression to simulate VTL behaviour
|
|
68
|
-
*/
|
|
69
|
-
var fakeExecute = function fakeExecute(bindings) {
|
|
70
|
-
return function (expression) {
|
|
71
|
-
var options = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
72
|
-
// Assume this code doesn't provide vulnerabilities (only in test)
|
|
73
|
-
// eslint-disable-next-line no-new-func
|
|
74
|
-
return _construct(Function, _toConsumableArray(Object.keys(bindings)).concat(["return ".concat(expression.value)])).apply(void 0, _toConsumableArray(Object.values(bindings).map(function (value) {
|
|
75
|
-
return options.iteration !== undefined && Array.isArray(value) ? value[options.iteration] : value;
|
|
76
|
-
})));
|
|
77
|
-
};
|
|
78
|
-
};
|
|
79
|
-
(0, _vitest.describe)('createRefreshCalculated', function () {
|
|
80
|
-
(0, _vitest.it)('should recalculate simple variable', function () {
|
|
81
|
-
var bindings = {
|
|
82
|
-
AGE: [10, 20, 30]
|
|
83
|
-
};
|
|
84
|
-
var _createRefreshCalcula = (0, _createRefreshCalculated["default"])({
|
|
85
|
-
variables: variables,
|
|
86
|
-
execute: fakeExecute(bindings),
|
|
87
|
-
bindings: bindings
|
|
88
|
-
}),
|
|
89
|
-
_createRefreshCalcula2 = _slicedToArray(_createRefreshCalcula, 1),
|
|
90
|
-
refresh = _createRefreshCalcula2[0];
|
|
91
|
-
(0, _vitest.expect)(refresh(variables, {}).COUNT_AGES).toBe(3);
|
|
92
|
-
(0, _vitest.expect)(refresh(variables, {
|
|
93
|
-
iteration: 1
|
|
94
|
-
}).COUNT_AGES).toBe(3);
|
|
95
|
-
(0, _vitest.expect)(bindings.AGE).toEqual([10, 20, 30]);
|
|
96
|
-
(0, _vitest.expect)(bindings.COUNT_AGES).toEqual(3);
|
|
97
|
-
});
|
|
98
|
-
(0, _vitest.it)('should recalculate loop variables', function () {
|
|
99
|
-
var bindings = {
|
|
100
|
-
AGE: [10, 20, 30]
|
|
101
|
-
};
|
|
102
|
-
var _createRefreshCalcula3 = (0, _createRefreshCalculated["default"])({
|
|
103
|
-
variables: variables,
|
|
104
|
-
execute: fakeExecute(bindings),
|
|
105
|
-
bindings: bindings
|
|
106
|
-
}),
|
|
107
|
-
_createRefreshCalcula4 = _slicedToArray(_createRefreshCalcula3, 1),
|
|
108
|
-
refresh = _createRefreshCalcula4[0];
|
|
109
|
-
(0, _vitest.expect)(refresh(variables).AGE_ONE_PLUS).toEqual([11, 21, 31]);
|
|
110
|
-
(0, _vitest.expect)(bindings.AGE).toEqual([10, 20, 30]);
|
|
111
|
-
(0, _vitest.expect)(bindings.AGE_ONE_PLUS).toEqual([11, 21, 31]);
|
|
112
|
-
});
|
|
113
|
-
(0, _vitest.it)('should recalculate loop variables with specific iteration', function () {
|
|
114
|
-
var bindings = {
|
|
115
|
-
AGE: [10, 20, 30]
|
|
116
|
-
};
|
|
117
|
-
var _createRefreshCalcula5 = (0, _createRefreshCalculated["default"])({
|
|
118
|
-
variables: variables,
|
|
119
|
-
execute: fakeExecute(bindings),
|
|
120
|
-
bindings: bindings
|
|
121
|
-
}),
|
|
122
|
-
_createRefreshCalcula6 = _slicedToArray(_createRefreshCalcula5, 1),
|
|
123
|
-
refresh = _createRefreshCalcula6[0];
|
|
124
|
-
(0, _vitest.expect)(refresh(variables, {
|
|
125
|
-
iteration: 1
|
|
126
|
-
}).AGE_ONE_PLUS).toEqual(21);
|
|
127
|
-
(0, _vitest.expect)(bindings.AGE).toEqual([10, 20, 30]);
|
|
128
|
-
(0, _vitest.expect)(bindings.AGE_ONE_PLUS).toEqual([11, 21, 31]);
|
|
129
|
-
});
|
|
130
|
-
});
|
|
@@ -1,90 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
exports.executeVtlExpression = executeVtlExpression;
|
|
8
|
-
var _trevas = require("@inseefr/trevas");
|
|
9
|
-
var _mdLabel = _interopRequireDefault(require("../../../components/commons/components/md-label"));
|
|
10
|
-
var _vtl = _interopRequireDefault(require("../../../utils/vtl"));
|
|
11
|
-
var _constants = require("../../../utils/constants");
|
|
12
|
-
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
15
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
16
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
18
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
19
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
20
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
21
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
22
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
23
|
-
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
24
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
25
|
-
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); }
|
|
26
|
-
function isDataSet(result) {
|
|
27
|
-
return _typeof(result) === 'object' && result !== null && 'dataPoints' in result && result.dataPoints !== null && _typeof(result.dataPoints) === 'object' && 'result' in result.dataPoints;
|
|
28
|
-
}
|
|
29
|
-
function extractDataSetResult(dataSet) {
|
|
30
|
-
var dataPoints = dataSet.dataPoints;
|
|
31
|
-
if (dataPoints) {
|
|
32
|
-
var result = dataPoints.result;
|
|
33
|
-
return result;
|
|
34
|
-
}
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Run a VTL expression and return the result
|
|
40
|
-
*/
|
|
41
|
-
function executeVtlExpression(expression, vtlBindings) {
|
|
42
|
-
// Make sur all values can be handled by VTL
|
|
43
|
-
var legalVtlBindings = Object.entries(vtlBindings).reduce(function (acc, _ref) {
|
|
44
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
45
|
-
k = _ref2[0],
|
|
46
|
-
v = _ref2[1];
|
|
47
|
-
return _objectSpread(_objectSpread({}, acc), {}, _defineProperty({}, k, (0, _vtl["default"])(v)));
|
|
48
|
-
}, {});
|
|
49
|
-
var result = (0, _trevas.interpret)(expression, legalVtlBindings);
|
|
50
|
-
if (isDataSet(result)) {
|
|
51
|
-
return extractDataSetResult(result);
|
|
52
|
-
}
|
|
53
|
-
if (result === null) {
|
|
54
|
-
return null;
|
|
55
|
-
}
|
|
56
|
-
if (_typeof(result) === 'object') {
|
|
57
|
-
return expression;
|
|
58
|
-
}
|
|
59
|
-
return result;
|
|
60
|
-
}
|
|
61
|
-
function executeVTL(expression, vtlBindings, logging) {
|
|
62
|
-
if (expression) {
|
|
63
|
-
try {
|
|
64
|
-
return executeVtlExpression(expression, vtlBindings);
|
|
65
|
-
} catch (e) {
|
|
66
|
-
logging(expression, vtlBindings, e);
|
|
67
|
-
return expression;
|
|
68
|
-
}
|
|
69
|
-
}
|
|
70
|
-
return '';
|
|
71
|
-
}
|
|
72
|
-
function loggingDefault(expression, bindings, e) {
|
|
73
|
-
if (process.env.NODE_ENV === 'development') {
|
|
74
|
-
console.warn("VTL error : ".concat(expression), bindings);
|
|
75
|
-
console.warn(e);
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
function executeExpression(vtlBindings, expression, type, features) {
|
|
79
|
-
var logging = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : loggingDefault;
|
|
80
|
-
if (features.includes(_constants.VTL) && type.includes(_constants.VTL)) {
|
|
81
|
-
var vtl = executeVTL(expression, vtlBindings, logging);
|
|
82
|
-
if (features.includes(_constants.MD) && type.includes(_constants.MD) && typeof vtl === 'string') return /*#__PURE__*/(0, _jsxRuntime.jsx)(_mdLabel["default"], {
|
|
83
|
-
expression: vtl
|
|
84
|
-
});
|
|
85
|
-
return vtl;
|
|
86
|
-
}
|
|
87
|
-
return expression;
|
|
88
|
-
}
|
|
89
|
-
var _default = executeExpression;
|
|
90
|
-
exports["default"] = _default;
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _vitest = require("vitest");
|
|
4
|
-
var _executeExpression = _interopRequireDefault(require("./execute-expression"));
|
|
5
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
6
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
7
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
9
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
10
|
-
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
11
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
-
(0, _vitest.describe)('executeVTL', function () {
|
|
13
|
-
var cases = [['"Hello World"', {}, 'Hello World'], ['1', {}, 1], ['true', {}, true], ['this is a string', {}, 'this is a string'], ['"Hello" || " World"', {}, 'Hello World'], ['"Hello" || W', {
|
|
14
|
-
W: ' World'
|
|
15
|
-
}, 'Hello World'], ['W = 2', {
|
|
16
|
-
W: 2
|
|
17
|
-
}, true], ['W = 1', {
|
|
18
|
-
W: 2
|
|
19
|
-
}, false], ['cast(AGE, integer)', {
|
|
20
|
-
AGE: '18'
|
|
21
|
-
}, 18], ['count(V)', {
|
|
22
|
-
V: [1, 2, 3]
|
|
23
|
-
}, 3], ['(READY)', {
|
|
24
|
-
READY: true
|
|
25
|
-
}, true]];
|
|
26
|
-
var _loop = function _loop() {
|
|
27
|
-
var _cases$_i = _slicedToArray(_cases[_i], 3),
|
|
28
|
-
expression = _cases$_i[0],
|
|
29
|
-
bindings = _cases$_i[1],
|
|
30
|
-
expectation = _cases$_i[2];
|
|
31
|
-
(0, _vitest.test)("it should convert `".concat(expression, "` into ").concat(JSON.stringify(expectation)), function () {
|
|
32
|
-
(0, _vitest.expect)((0, _executeExpression["default"])(bindings, expression, 'VTL', ['VTL'])).toBe(expectation);
|
|
33
|
-
});
|
|
34
|
-
};
|
|
35
|
-
for (var _i = 0, _cases = cases; _i < _cases.length; _i++) {
|
|
36
|
-
_loop();
|
|
37
|
-
}
|
|
38
|
-
});
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _vtl = require("@inseefr/vtl-2.0-antlr-tools");
|
|
8
|
-
var _antlr = _interopRequireDefault(require("antlr4"));
|
|
9
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
|
-
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
11
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
12
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
13
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
14
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
15
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
16
|
-
/**
|
|
17
|
-
* Find variables used in an expression
|
|
18
|
-
*/
|
|
19
|
-
function getExpressionVariables(expression, variables) {
|
|
20
|
-
try {
|
|
21
|
-
var chars = new _antlr["default"].InputStream(expression);
|
|
22
|
-
var lexer = new _vtl.VtlLexer(chars);
|
|
23
|
-
return lexer.getAllTokens().reduce(function (array, _ref) {
|
|
24
|
-
var start = _ref.start,
|
|
25
|
-
stop = _ref.stop,
|
|
26
|
-
type = _ref.type;
|
|
27
|
-
if (type === 234) {
|
|
28
|
-
var token = expression.substring(start, stop + 1);
|
|
29
|
-
if (array.indexOf(token) === -1 && token in variables) {
|
|
30
|
-
return [].concat(_toConsumableArray(array), [token]);
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
return array;
|
|
34
|
-
}, []);
|
|
35
|
-
} catch (e) {
|
|
36
|
-
return [];
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
var _default = getExpressionVariables;
|
|
40
|
-
exports["default"] = _default;
|
|
@@ -1,31 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
var _vitest = require("vitest");
|
|
4
|
-
var _getExpressionsVariables = _interopRequireDefault(require("./get-expressions-variables"));
|
|
5
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
6
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
7
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
9
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
10
|
-
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
11
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
12
|
-
(0, _vitest.describe)('getExpressionVariables', function () {
|
|
13
|
-
var cases = [['(READY)', ['READY']]];
|
|
14
|
-
var declaredVariables = {
|
|
15
|
-
READY: {
|
|
16
|
-
type: 'COLLECTED',
|
|
17
|
-
value: true
|
|
18
|
-
}
|
|
19
|
-
};
|
|
20
|
-
var _loop = function _loop() {
|
|
21
|
-
var _cases$_i = _slicedToArray(_cases[_i], 2),
|
|
22
|
-
expression = _cases$_i[0],
|
|
23
|
-
variables = _cases$_i[1];
|
|
24
|
-
(0, _vitest.test)("it should convert find variables in `".concat(expression, "`"), function () {
|
|
25
|
-
(0, _vitest.expect)((0, _getExpressionsVariables["default"])(expression, declaredVariables)).toEqual(variables);
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
for (var _i = 0, _cases = cases; _i < _cases.length; _i++) {
|
|
29
|
-
_loop();
|
|
30
|
-
}
|
|
31
|
-
});
|
|
@@ -1,35 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
var _constants = require("../../../utils/constants");
|
|
8
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
9
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
10
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
12
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
13
|
-
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); }
|
|
14
|
-
/**
|
|
15
|
-
* Convert an unknown variable into a valid VTL expression object
|
|
16
|
-
*/
|
|
17
|
-
function getSafetyExpression(expression) {
|
|
18
|
-
if (typeof expression === 'string') {
|
|
19
|
-
return {
|
|
20
|
-
value: expression,
|
|
21
|
-
type: _constants.VTL
|
|
22
|
-
};
|
|
23
|
-
}
|
|
24
|
-
// TODO: fix into model and supress this block
|
|
25
|
-
if (expression && _typeof(expression) === 'object' && 'value' in expression && !('type' in expression)) {
|
|
26
|
-
return _objectSpread(_objectSpread({}, expression), {}, {
|
|
27
|
-
type: _constants.VTL
|
|
28
|
-
});
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
// TODO: ensure we really have an expression here or throw an error
|
|
32
|
-
return expression;
|
|
33
|
-
}
|
|
34
|
-
var _default = getSafetyExpression;
|
|
35
|
-
exports["default"] = _default;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "default", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _createExecuteExpression["default"];
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
var _createExecuteExpression = _interopRequireDefault(require("./create-execute-expression"));
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
@@ -1,174 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = void 0;
|
|
7
|
-
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); }
|
|
8
|
-
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
9
|
-
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i["return"] && (_r = _i["return"](), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
10
|
-
function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); }
|
|
11
|
-
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
12
|
-
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
13
|
-
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
14
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
15
|
-
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
16
|
-
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
|
-
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
18
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
19
|
-
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
20
|
-
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
21
|
-
function isInSubPage(state) {
|
|
22
|
-
return state.pager.subPage !== undefined;
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
/**
|
|
26
|
-
* Add the value from variable indexed by response name
|
|
27
|
-
*/
|
|
28
|
-
function mergeResponse(_ref) {
|
|
29
|
-
var map = _ref.map,
|
|
30
|
-
response = _ref.response,
|
|
31
|
-
variables = _ref.variables;
|
|
32
|
-
var name = response.name;
|
|
33
|
-
if (name in variables) {
|
|
34
|
-
return _objectSpread(_objectSpread({}, map), {}, _defineProperty({}, name, variables[name].value));
|
|
35
|
-
}
|
|
36
|
-
return map;
|
|
37
|
-
}
|
|
38
|
-
function collecteArrayResponses(_ref2) {
|
|
39
|
-
var components = _ref2.components,
|
|
40
|
-
variables = _ref2.variables,
|
|
41
|
-
_ref2$map = _ref2.map,
|
|
42
|
-
map = _ref2$map === void 0 ? {} : _ref2$map;
|
|
43
|
-
return components.reduce(function (sub, component) {
|
|
44
|
-
return collecteComponentResponse({
|
|
45
|
-
component: component,
|
|
46
|
-
variables: variables,
|
|
47
|
-
map: sub
|
|
48
|
-
});
|
|
49
|
-
}, map);
|
|
50
|
-
}
|
|
51
|
-
function collectCell(_ref3) {
|
|
52
|
-
var cell = _ref3.cell,
|
|
53
|
-
variables = _ref3.variables,
|
|
54
|
-
map = _ref3.map;
|
|
55
|
-
var _cell = _toArray(cell),
|
|
56
|
-
component = _cell[0],
|
|
57
|
-
rest = _cell.slice(1);
|
|
58
|
-
var componentType = component.componentType;
|
|
59
|
-
var next = map;
|
|
60
|
-
if (componentType) {
|
|
61
|
-
next = _objectSpread(_objectSpread({}, map), collecteComponentResponse({
|
|
62
|
-
component: component,
|
|
63
|
-
variables: variables,
|
|
64
|
-
map: map
|
|
65
|
-
}));
|
|
66
|
-
}
|
|
67
|
-
if (rest.length) {
|
|
68
|
-
return collectCell({
|
|
69
|
-
cell: rest,
|
|
70
|
-
variables: variables,
|
|
71
|
-
map: next
|
|
72
|
-
});
|
|
73
|
-
}
|
|
74
|
-
return next;
|
|
75
|
-
}
|
|
76
|
-
function collectTableResponse(_ref4) {
|
|
77
|
-
var map = _ref4.map,
|
|
78
|
-
body = _ref4.body,
|
|
79
|
-
variables = _ref4.variables;
|
|
80
|
-
if (Array.isArray(body)) {
|
|
81
|
-
return body.reduce(function (sub, cell) {
|
|
82
|
-
if (Array.isArray(cell)) {
|
|
83
|
-
return collectCell({
|
|
84
|
-
cell: cell,
|
|
85
|
-
variables: variables,
|
|
86
|
-
map: sub
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
return sub;
|
|
90
|
-
}, map);
|
|
91
|
-
}
|
|
92
|
-
return map;
|
|
93
|
-
}
|
|
94
|
-
function collecteComponentResponse(_ref5) {
|
|
95
|
-
var component = _ref5.component,
|
|
96
|
-
variables = _ref5.variables,
|
|
97
|
-
_ref5$map = _ref5.map,
|
|
98
|
-
map = _ref5$map === void 0 ? {} : _ref5$map;
|
|
99
|
-
if ('body' in component && component.body) {
|
|
100
|
-
return collectTableResponse({
|
|
101
|
-
map: map,
|
|
102
|
-
body: component.body,
|
|
103
|
-
variables: variables
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
if ('response' in component) {
|
|
107
|
-
return mergeResponse({
|
|
108
|
-
map: map,
|
|
109
|
-
response: component.response,
|
|
110
|
-
variables: variables
|
|
111
|
-
});
|
|
112
|
-
}
|
|
113
|
-
if ('components' in component) {
|
|
114
|
-
return collecteArrayResponses({
|
|
115
|
-
components: component.components,
|
|
116
|
-
variables: variables,
|
|
117
|
-
map: map
|
|
118
|
-
});
|
|
119
|
-
}
|
|
120
|
-
if ('responses' in component) {
|
|
121
|
-
// TODO : Understand this cause types doesn't match
|
|
122
|
-
return collecteArrayResponses({
|
|
123
|
-
components: component.responses,
|
|
124
|
-
variables: variables,
|
|
125
|
-
map: map
|
|
126
|
-
});
|
|
127
|
-
}
|
|
128
|
-
return map;
|
|
129
|
-
}
|
|
130
|
-
function checkArrayForSubPage(map, state) {
|
|
131
|
-
var pager = state.pager;
|
|
132
|
-
var iteration = pager.iteration;
|
|
133
|
-
return Object.entries(map).reduce(function (sub, _ref6) {
|
|
134
|
-
var _ref7 = _slicedToArray(_ref6, 2),
|
|
135
|
-
name = _ref7[0],
|
|
136
|
-
value = _ref7[1];
|
|
137
|
-
if (value && Array.isArray(value) && iteration !== undefined) {
|
|
138
|
-
return _objectSpread(_objectSpread({}, sub), {}, _defineProperty({}, name, value[iteration]));
|
|
139
|
-
}
|
|
140
|
-
return _objectSpread(_objectSpread({}, sub), {}, _defineProperty({}, name, value));
|
|
141
|
-
}, {});
|
|
142
|
-
}
|
|
143
|
-
function checkUseContext(map, state) {
|
|
144
|
-
if (isInSubPage(state)) {
|
|
145
|
-
return checkArrayForSubPage(map, state);
|
|
146
|
-
}
|
|
147
|
-
return map;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
|
-
/**
|
|
151
|
-
* The component provide a direct response (not a loop, roster...)
|
|
152
|
-
*/
|
|
153
|
-
function isSimpleComponent(component) {
|
|
154
|
-
return 'response' in component && _typeof(component.response) === 'object';
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
/**
|
|
158
|
-
* Get the value from the component
|
|
159
|
-
*/
|
|
160
|
-
function getComponentValue(component, state) {
|
|
161
|
-
var variables = state.variables;
|
|
162
|
-
var map = checkUseContext(collecteComponentResponse({
|
|
163
|
-
component: component,
|
|
164
|
-
variables: variables
|
|
165
|
-
}), state);
|
|
166
|
-
if (isSimpleComponent(component)) {
|
|
167
|
-
var response = component.response;
|
|
168
|
-
var name = response.name;
|
|
169
|
-
return map[name];
|
|
170
|
-
}
|
|
171
|
-
return map;
|
|
172
|
-
}
|
|
173
|
-
var _default = getComponentValue;
|
|
174
|
-
exports["default"] = _default;
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
Object.defineProperty(exports, "default", {
|
|
7
|
-
enumerable: true,
|
|
8
|
-
get: function get() {
|
|
9
|
-
return _getComponentValue["default"];
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
var _getComponentValue = _interopRequireDefault(require("./get-component-value"));
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|