@inseefr/lunatic 2.6.3-rc.1 → 2.6.3
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 +49 -3
- package/lib/components/checkbox/checkbox-boolean/html/checkbox-boolean.js +3 -3
- package/lib/components/checkbox/checkbox-boolean/lunatic-checkbox-boolean.js +7 -1
- package/lib/components/checkbox/checkbox-group/checkbox-group-content.js +0 -2
- package/lib/components/checkbox/checkbox-group/html/checkbox-group-content.js +4 -2
- package/lib/components/checkbox/checkbox-group/html/checkbox-group.js +3 -3
- package/lib/components/checkbox/checkbox-group/lunatic-checkbox-group.js +2 -1
- package/lib/components/checkbox/checkbox-one/lunatic-checkbox-one.js +2 -1
- package/lib/components/checkbox/commons/checkbox-option.js +3 -1
- package/lib/components/commons/components/combo-box/combo-box-container.js +1 -2
- package/lib/components/commons/components/combo-box/combo-box.js +2 -2
- package/lib/components/commons/components/combo-box/selection/LabelOrInput.js +3 -1
- package/lib/components/commons/components/combo-box/selection/input.js +3 -1
- package/lib/components/commons/components/combo-box/selection/selection.js +3 -1
- package/lib/components/commons/components/errors/errors.js +12 -10
- package/lib/components/commons/components/errors/errors.spec.js +6 -6
- package/lib/components/component-set/html/__snapshots__/component-set.spec.tsx.snap +2 -0
- package/lib/components/component-set/html/component-set.js +2 -2
- package/lib/components/datepicker/html/__snapshots__/datepicker.spec.tsx.snap +2 -0
- package/lib/components/datepicker/html/datepicker-input.js +4 -2
- package/lib/components/datepicker/html/datepicker.js +3 -3
- package/lib/components/datepicker/lunatic-datepicker.js +2 -1
- package/lib/components/dropdown/lunatic-dropdown.js +2 -1
- package/lib/components/index.js +4 -4
- package/lib/components/input/html/__snapshots__/input.spec.tsx.snap +2 -0
- package/lib/components/input/html/input.js +3 -3
- package/lib/components/input/lunatic-input.js +2 -1
- package/lib/components/input-number/html/__snapshots__/input-number.spec.tsx.snap +2 -2
- package/lib/components/input-number/html/input-number-thousand.js +4 -17
- package/lib/components/input-number/html/input-number.js +3 -5
- package/lib/components/input-number/lunatic-input-number.js +2 -3
- package/lib/components/loop/block-for-loop.js +10 -6
- package/lib/components/loop/roster-for-loop/roster-for-loop.js +35 -27
- package/lib/components/loop/utils/get-initial-nb-rows.js +17 -0
- package/lib/components/lunatic-components.js +7 -27
- package/lib/components/pairwise-links/index.js +13 -0
- package/lib/components/pairwise-links/orchestrator.js +71 -0
- package/lib/components/pairwise-links/pairwise-links.js +30 -27
- package/lib/components/pairwise-links/row.js +74 -0
- package/lib/components/radio/html/radio-group-content.js +4 -2
- package/lib/components/radio/html/radio-group.js +3 -3
- package/lib/components/radio/html/radio-option.js +3 -1
- package/lib/components/radio/lunatic-radio-group.js +2 -1
- package/lib/components/suggester/find-best-label/find-best-label.js +6 -6
- package/lib/components/suggester/idb-suggester/idb-suggester.js +4 -3
- package/lib/components/suggester/lunatic-suggester.js +7 -4
- package/lib/components/suggester/searching/create-searching.js +20 -39
- package/lib/components/switch/html/switch.js +2 -2
- package/lib/components/switch/lunatic-switch.js +2 -1
- package/lib/components/table/cell.js +89 -0
- package/lib/components/table/{table-header.js → header.js} +5 -3
- package/lib/components/table/index.js +13 -0
- package/lib/components/table/lunatic-table.js +15 -24
- package/lib/components/table/row.js +40 -0
- package/lib/components/table/table-orchestrator.js +35 -0
- package/lib/components/textarea/html/__snapshots__/textarea.spec.tsx.snap +2 -0
- package/lib/components/textarea/html/textarea.js +6 -4
- package/lib/components/textarea/lunatic-textarea.js +6 -3
- package/lib/hooks/use-auto-focus.js +26 -0
- package/lib/src/components/checkbox/checkbox-boolean/html/checkbox-boolean.d.ts +1 -1
- package/lib/src/components/checkbox/checkbox-group/html/checkbox-group-content.d.ts +2 -1
- package/lib/src/components/checkbox/checkbox-group/html/checkbox-group.d.ts +1 -1
- package/lib/src/components/checkbox/commons/checkbox-option.d.ts +1 -0
- package/lib/src/components/commons/components/combo-box/combo-box-container.d.ts +2 -2
- package/lib/src/components/commons/components/combo-box/combo-box.d.ts +2 -2
- package/lib/src/components/commons/components/combo-box/combo-box.stories.d.ts +4 -6
- package/lib/src/components/commons/components/combo-box/selection/LabelOrInput.d.ts +1 -0
- package/lib/src/components/commons/components/combo-box/selection/input.d.ts +1 -0
- package/lib/src/components/commons/components/combo-box/selection/selection.d.ts +2 -1
- package/lib/src/components/commons/components/errors/errors.d.ts +6 -3
- package/lib/src/components/datepicker/html/datepicker-input.d.ts +2 -1
- package/lib/src/components/datepicker/html/datepicker.d.ts +1 -1
- package/lib/src/components/dropdown/html/dropdown-writable/dropdown-writable.d.ts +1 -1
- package/lib/src/components/dropdown/html/dropdown.d.ts +3 -1
- package/lib/src/components/index.d.ts +2 -2
- package/lib/src/components/input/html/input.d.ts +2 -2
- package/lib/src/components/input-number/html/input-number-thousand.d.ts +2 -2
- package/lib/src/components/input-number/html/input-number.d.ts +2 -3
- package/lib/src/components/loop/block-for-loop.d.ts +4 -3
- package/lib/src/components/loop/roster-for-loop/roster-for-loop.d.ts +4 -3
- package/lib/src/components/loop/utils/get-initial-nb-rows.d.ts +4 -0
- package/lib/src/components/lunatic-components.d.ts +3 -5
- package/lib/src/components/pairwise-links/index.d.ts +1 -0
- package/lib/src/components/pairwise-links/orchestrator.d.ts +6 -0
- package/lib/src/components/pairwise-links/pairwise-links.d.ts +2 -1
- package/lib/src/components/pairwise-links/row.d.ts +7 -0
- package/lib/src/components/radio/html/radio-group-content.d.ts +2 -1
- package/lib/src/components/radio/html/radio-group.d.ts +1 -1
- package/lib/src/components/radio/html/radio-option.d.ts +1 -0
- package/lib/src/components/suggester/find-best-label/find-best-label.d.ts +1 -1
- package/lib/src/components/suggester/html/suggester.d.ts +1 -1
- package/lib/src/components/suggester/idb-suggester/idb-suggester.d.ts +5 -2
- package/lib/src/components/suggester/lunatic-suggester.d.ts +1 -1
- package/lib/src/components/suggester/searching/create-searching.d.ts +1 -1
- package/lib/src/components/switch/html/switch.d.ts +1 -1
- package/lib/src/components/table/cell.d.ts +19 -0
- package/lib/src/components/table/{table-header.d.ts → header.d.ts} +2 -2
- package/lib/src/components/table/index.d.ts +1 -0
- package/lib/src/components/table/lunatic-table.d.ts +1 -1
- package/lib/src/components/table/row.d.ts +18 -0
- package/lib/src/components/table/table-orchestrator.d.ts +4 -0
- package/lib/src/components/textarea/html/textarea.d.ts +3 -2
- package/lib/src/components/type.d.ts +9 -7
- package/lib/src/hooks/use-auto-focus.d.ts +6 -0
- package/lib/src/use-lunatic/actions.d.ts +19 -3
- package/lib/src/use-lunatic/commons/calculated-variables.d.ts +8 -0
- package/lib/src/use-lunatic/commons/compile-controls.d.ts +2 -3
- package/lib/src/use-lunatic/commons/execute-expression/create-execute-expression.d.ts +9 -0
- package/lib/src/use-lunatic/commons/execute-expression/create-memoizer.d.ts +8 -0
- package/lib/src/use-lunatic/commons/execute-expression/create-refresh-calculated.d.ts +24 -0
- package/lib/src/use-lunatic/commons/execute-expression/execute-expression.d.ts +11 -0
- package/lib/src/use-lunatic/commons/execute-expression/get-expressions-variables.d.ts +7 -0
- package/lib/src/use-lunatic/commons/execute-expression/get-expressions-variables.spec.d.ts +1 -0
- package/lib/src/use-lunatic/commons/execute-expression/get-safety-expression.d.ts +6 -0
- package/lib/src/use-lunatic/commons/execute-expression/index.d.ts +1 -0
- package/lib/src/use-lunatic/commons/fill-components/fill-component-required.d.ts +418 -0
- package/lib/src/use-lunatic/commons/fill-components/fill-component-value.d.ts +3 -2
- package/lib/src/use-lunatic/commons/fill-components/fill-components.d.ts +0 -6
- package/lib/src/use-lunatic/commons/fill-components/fill-from-state.d.ts +142 -107
- package/lib/src/use-lunatic/commons/fill-components/fill-specific-expression.d.ts +89 -53
- package/lib/src/use-lunatic/commons/get-compatible-vtl-expression.d.ts +0 -1
- package/lib/src/use-lunatic/commons/get-component-value/get-component-value.d.ts +6 -0
- package/lib/src/use-lunatic/commons/get-component-value/index.d.ts +1 -0
- package/lib/src/use-lunatic/commons/get-data.d.ts +26 -0
- package/lib/src/use-lunatic/commons/index.d.ts +3 -0
- package/lib/src/use-lunatic/reducer/overview/overview-on-init.d.ts +9 -10
- package/lib/src/use-lunatic/reducer/reduce-handle-change/index.d.ts +1 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-cleaning.d.ts +7 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-cleaning.spec.d.ts +1 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-handle-change.d.ts +4 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-links-variable.d.ts +15 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-missing.d.ts +7 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-resizing.d.ts +4 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-variables-array.d.ts +14 -0
- package/lib/src/use-lunatic/reducer/reduce-handle-change/reduce-variables-simple.d.ts +9 -0
- package/lib/src/use-lunatic/reducer/reduce-on-init.d.ts +12 -1
- package/lib/src/use-lunatic/reducer/reduce-on-init.spec.d.ts +1 -0
- package/lib/src/use-lunatic/type-source.d.ts +21 -7
- package/lib/src/use-lunatic/type.d.ts +12 -13
- package/lib/src/use-lunatic/use-lunatic.d.ts +62 -36
- package/lib/src/use-lunatic/use-suggesters.d.ts +2 -1
- package/lib/src/utils/array.d.ts +1 -6
- package/lib/src/utils/number.d.ts +0 -4
- package/lib/src/utils/suggester-workers/append-to-index/create-append-task.d.ts +1 -1
- package/lib/src/utils/suggester-workers/worker-path.d.ts +6 -0
- package/lib/src/utils/vtl/dataset-builder.d.ts +5 -0
- package/lib/src/utils/vtl/index.d.ts +1 -0
- package/lib/stories/behaviour/cleaning/source.json +151 -0
- package/lib/stories/behaviour/cleaning/test.stories.js +84 -0
- package/lib/stories/{questionnaires-test → behaviour}/controls/controls.stories.js +5 -5
- package/lib/stories/{questionnaires-test → behaviour/others}/test.stories.js +7 -7
- package/lib/stories/{paste-questionnaire → behaviour/paste}/test.stories.js +3 -3
- package/lib/stories/{resizing-questionnaire → behaviour/resizing}/test.stories.js +3 -3
- package/lib/use-lunatic/actions.js +3 -3
- package/lib/use-lunatic/commons/calculated-variables.js +104 -0
- package/lib/use-lunatic/commons/compile-controls.js +5 -3
- package/lib/use-lunatic/commons/execute-condition-filter.js +9 -1
- package/lib/use-lunatic/commons/execute-expression/create-execute-expression.js +233 -0
- package/lib/use-lunatic/commons/execute-expression/create-execute-expression.spec.js +155 -0
- package/lib/use-lunatic/commons/execute-expression/create-memoizer.js +63 -0
- package/lib/use-lunatic/commons/execute-expression/create-refresh-calculated.js +149 -0
- package/lib/use-lunatic/commons/execute-expression/create-refresh-calculated.spec.js +130 -0
- package/lib/use-lunatic/commons/execute-expression/execute-expression.js +90 -0
- package/lib/use-lunatic/commons/execute-expression/execute-expression.spec.js +38 -0
- package/lib/use-lunatic/commons/execute-expression/get-expressions-variables.js +40 -0
- package/lib/use-lunatic/commons/execute-expression/get-expressions-variables.spec.js +31 -0
- package/lib/use-lunatic/commons/{fill-components/fill-iterations.js → execute-expression/get-safety-expression.js} +20 -30
- package/lib/use-lunatic/commons/execute-expression/index.js +13 -0
- package/lib/use-lunatic/commons/fill-components/fill-component-expressions.js +3 -2
- package/lib/use-lunatic/{reducer/reduce-handle-change.js → commons/fill-components/fill-component-required.js} +8 -14
- package/lib/use-lunatic/commons/fill-components/fill-component-value.js +7 -21
- package/lib/use-lunatic/commons/fill-components/fill-components.js +4 -5
- package/lib/use-lunatic/commons/fill-components/fill-from-state.js +2 -0
- package/lib/use-lunatic/commons/fill-components/fill-missing-response.js +13 -6
- package/lib/use-lunatic/commons/fill-components/fill-specific-expression.js +5 -58
- package/lib/use-lunatic/commons/get-compatible-vtl-expression.js +0 -1
- package/lib/use-lunatic/commons/get-component-value/get-component-value.js +174 -0
- package/lib/use-lunatic/commons/get-component-value/index.js +13 -0
- package/lib/use-lunatic/commons/get-data.js +80 -0
- package/lib/use-lunatic/commons/index.js +21 -0
- package/lib/use-lunatic/initial-state.js +4 -6
- package/lib/use-lunatic/reducer/overview/overview-on-change.js +1 -1
- package/lib/use-lunatic/reducer/reduce-handle-change/__mocks__/source-cleaning-loop.json +792 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/index.js +13 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-cleaning.js +78 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-cleaning.spec.js +46 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-handle-change.js +115 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-links-variable.js +89 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-missing.js +88 -0
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-resizing.js +119 -0
- package/lib/use-lunatic/{commons/variables/get-questionnaire-data.js → reducer/reduce-handle-change/reduce-variables-array.js} +32 -53
- package/lib/use-lunatic/reducer/reduce-handle-change/reduce-variables-simple.js +28 -0
- package/lib/use-lunatic/reducer/reduce-on-init.js +184 -90
- package/lib/use-lunatic/reducer/reduce-on-init.spec.js +17 -0
- package/lib/use-lunatic/reducer/reducer.js +2 -2
- package/lib/use-lunatic/reducer/resolve-component-controls/resolve-simple-control.js +4 -2
- package/lib/use-lunatic/use-lunatic.js +29 -22
- package/lib/use-lunatic/use-lunatic.test.js +36 -133
- package/lib/use-lunatic/use-suggesters.js +4 -3
- package/lib/utils/array.js +6 -57
- package/lib/utils/get-component-value.js +9 -3
- package/lib/utils/number.js +1 -13
- package/lib/utils/suggester-workers/append-to-index/create-append-task.js +4 -3
- package/lib/utils/suggester-workers/worker-path.js +29 -0
- package/lib/utils/vtl/dataset-builder.js +27 -0
- package/lib/utils/vtl/index.js +13 -0
- package/package.json +15 -10
- package/scripts/build/add-workers-to-public.js +44 -0
- package/scripts/build/workers-paths.js +44 -0
- package/workers-release/lunatic-append-worker-0.3.0-experimental.js +2 -0
- package/workers-release/lunatic-append-worker-0.3.0-experimental.js.LICENSE.txt +34 -0
- package/workers-release/lunatic-label-worker-0.3.0-experimental.js +2 -0
- package/workers-release/lunatic-label-worker-0.3.0-experimental.js.LICENSE.txt +13 -0
- package/workers-release/lunatic-searching-worker-0.3.0-experimental.js +2 -0
- package/workers-release/lunatic-searching-worker-0.3.0-experimental.js.LICENSE.txt +34 -0
- package/lib/hooks/use-track-changes.js +0 -50
- package/lib/src/hooks/use-track-changes.d.ts +0 -9
- package/lib/src/use-lunatic/commons/component.d.ts +0 -22
- package/lib/src/use-lunatic/commons/fill-components/fill-iterations.d.ts +0 -112
- package/lib/src/use-lunatic/commons/variables/behaviours/cleaning-behaviour.d.ts +0 -7
- package/lib/src/use-lunatic/commons/variables/behaviours/missing-behaviour.d.ts +0 -7
- package/lib/src/use-lunatic/commons/variables/behaviours/resizing-behaviour.d.ts +0 -7
- package/lib/src/use-lunatic/commons/variables/get-questionnaire-data.d.ts +0 -4
- package/lib/src/use-lunatic/commons/variables/lunatic-variables-store.d.ts +0 -77
- package/lib/src/use-lunatic/reducer/reduce-handle-change.d.ts +0 -6
- package/lib/src/utils/env.d.ts +0 -1
- package/lib/src/utils/store-tools/worker-path.d.ts +0 -1
- package/lib/src/utils/variables.d.ts +0 -5
- package/lib/src/utils/vtl.d.ts +0 -14
- package/lib/use-lunatic/commons/component.js +0 -22
- package/lib/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js +0 -39
- package/lib/use-lunatic/commons/variables/behaviours/missing-behaviour.js +0 -47
- package/lib/use-lunatic/commons/variables/behaviours/resizing-behaviour.js +0 -78
- package/lib/use-lunatic/commons/variables/lunatic-variables-store.js +0 -330
- package/lib/use-lunatic/commons/variables/lunatic-variables-store.spec.js +0 -216
- package/lib/utils/array.spec.js +0 -30
- package/lib/utils/env.js +0 -10
- package/lib/utils/store-tools/worker-path.js +0 -13
- package/lib/utils/suggester-workers/create-worker.js +0 -55
- package/lib/utils/variables.js +0 -37
- package/lib/utils/vtl.js +0 -100
- /package/lib/src/use-lunatic/commons/{variables/lunatic-variables-store.spec.d.ts → execute-expression/create-refresh-calculated.spec.d.ts} +0 -0
- /package/lib/src/{utils/array.spec.d.ts → use-lunatic/commons/execute-expression/execute-expression.spec.d.ts} +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_ControlesNonNum_horsBoucle_PasPageFin.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_ControlesNum_horsBoucle_PasPageFin.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_Controles_BouclesLiees2_PasPageFin.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_Controles_BouclesLiees_PasPageFin.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/boucles-n.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/controls-externes.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/controls-externes.stories.js +0 -0
- /package/lib/stories/{questionnaires-test → behaviour/others}/V2_DeclarationsSimples.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour/others}/V2_MinMaxSum_Boucles.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour/others}/V2_QuestSimple_Boucles.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour/others}/V2_TCMRallyeGames.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour/others}/test-dylan.json +0 -0
- /package/lib/stories/{paste-questionnaire → behaviour/paste}/source.json +0 -0
- /package/lib/stories/{resizing-questionnaire → behaviour/resizing}/source.json +0 -0
|
@@ -5,8 +5,9 @@ var _vitest = require("vitest");
|
|
|
5
5
|
var _useLunatic = _interopRequireDefault(require("./use-lunatic"));
|
|
6
6
|
var _source = _interopRequireDefault(require("../stories/overview/source.json"));
|
|
7
7
|
var _source2 = _interopRequireDefault(require("../stories/questionnaires/logement/source.json"));
|
|
8
|
-
var _source3 = _interopRequireDefault(require("../stories/
|
|
8
|
+
var _source3 = _interopRequireDefault(require("../stories/questionnaires/simpsons/source.json"));
|
|
9
9
|
var _source4 = _interopRequireDefault(require("../stories/component-set/source.json"));
|
|
10
|
+
var _source5 = _interopRequireDefault(require("../stories/behaviour/cleaning/source.json"));
|
|
10
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
12
|
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); }
|
|
12
13
|
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; }
|
|
@@ -38,7 +39,7 @@ var dataFromObject = function dataFromObject(o) {
|
|
|
38
39
|
result = _renderHook.result;
|
|
39
40
|
(0, _vitest.expect)(result.current.pager.page).toBe('1');
|
|
40
41
|
(0, _vitest.expect)(result.current.pager.lastReachedPage).toBe('1');
|
|
41
|
-
(0, _vitest.expect)(result.current.pager.maxPage).toBe('
|
|
42
|
+
(0, _vitest.expect)(result.current.pager.maxPage).toBe('39');
|
|
42
43
|
});
|
|
43
44
|
(0, _vitest.it)('should go to the next page correcly', function () {
|
|
44
45
|
var _renderHook2 = (0, _reactHooks.renderHook)(function () {
|
|
@@ -168,12 +169,43 @@ var dataFromObject = function dataFromObject(o) {
|
|
|
168
169
|
});
|
|
169
170
|
});
|
|
170
171
|
});
|
|
172
|
+
(0, _vitest.describe)('cleaning', function () {
|
|
173
|
+
(0, _vitest.it)('should call handleChange on cleaned variable', function () {
|
|
174
|
+
var spy = _vitest.vi.fn();
|
|
175
|
+
var _renderHook10 = (0, _reactHooks.renderHook)(function () {
|
|
176
|
+
return (0, _useLunatic["default"])(_source5["default"], undefined, {
|
|
177
|
+
onChange: spy
|
|
178
|
+
});
|
|
179
|
+
}),
|
|
180
|
+
result = _renderHook10.result;
|
|
181
|
+
result.current.onChange({
|
|
182
|
+
name: 'ORIGIN'
|
|
183
|
+
}, 'FR');
|
|
184
|
+
(0, _vitest.expect)(spy).toHaveBeenCalledTimes(1);
|
|
185
|
+
(0, _vitest.expect)(spy.mock.calls[0][0]).toEqual({
|
|
186
|
+
name: 'ORIGIN'
|
|
187
|
+
});
|
|
188
|
+
(0, _vitest.expect)(spy.mock.calls[0][1]).toEqual('FR');
|
|
189
|
+
result.current.onChange({
|
|
190
|
+
name: 'ORIGIN'
|
|
191
|
+
}, 'US');
|
|
192
|
+
(0, _vitest.expect)(spy).toHaveBeenCalledTimes(3);
|
|
193
|
+
(0, _vitest.expect)(spy.mock.calls[1][0]).toEqual({
|
|
194
|
+
name: 'CITY'
|
|
195
|
+
});
|
|
196
|
+
(0, _vitest.expect)(spy.mock.calls[1][1]).toEqual(null);
|
|
197
|
+
(0, _vitest.expect)(spy.mock.calls[2][0]).toEqual({
|
|
198
|
+
name: 'ORIGIN'
|
|
199
|
+
});
|
|
200
|
+
(0, _vitest.expect)(spy.mock.calls[2][1]).toEqual('US');
|
|
201
|
+
});
|
|
202
|
+
});
|
|
171
203
|
(0, _vitest.describe)('getComponents()', function () {
|
|
172
204
|
(0, _vitest.describe)('componentSet', function () {
|
|
173
|
-
var
|
|
205
|
+
var _renderHook11 = (0, _reactHooks.renderHook)(function () {
|
|
174
206
|
return (0, _useLunatic["default"])(_source4["default"], undefined, {});
|
|
175
207
|
}),
|
|
176
|
-
result =
|
|
208
|
+
result = _renderHook11.result;
|
|
177
209
|
var getComponents = function getComponents() {
|
|
178
210
|
return result.current.getComponents();
|
|
179
211
|
};
|
|
@@ -193,133 +225,4 @@ var dataFromObject = function dataFromObject(o) {
|
|
|
193
225
|
});
|
|
194
226
|
});
|
|
195
227
|
});
|
|
196
|
-
(0, _vitest.describe)('getData()', function () {
|
|
197
|
-
var hookRef;
|
|
198
|
-
(0, _vitest.beforeEach)(function () {
|
|
199
|
-
var _renderHook11 = (0, _reactHooks.renderHook)(function () {
|
|
200
|
-
return (0, _useLunatic["default"])(_source3["default"], undefined, {});
|
|
201
|
-
}),
|
|
202
|
-
result = _renderHook11.result;
|
|
203
|
-
(0, _reactHooks.act)(function () {
|
|
204
|
-
result.current.onChange({
|
|
205
|
-
name: 'COMMENT'
|
|
206
|
-
}, 'Mon commentaire');
|
|
207
|
-
result.current.onChange({
|
|
208
|
-
name: 'READY'
|
|
209
|
-
}, true);
|
|
210
|
-
});
|
|
211
|
-
hookRef = result;
|
|
212
|
-
});
|
|
213
|
-
(0, _vitest.it)('should return every value', function () {
|
|
214
|
-
var data = hookRef.current.getData(false);
|
|
215
|
-
(0, _vitest.expect)(data).toMatchObject({
|
|
216
|
-
COLLECTED: {
|
|
217
|
-
COMMENT: {
|
|
218
|
-
COLLECTED: 'Mon commentaire'
|
|
219
|
-
},
|
|
220
|
-
READY: {
|
|
221
|
-
COLLECTED: true
|
|
222
|
-
}
|
|
223
|
-
}
|
|
224
|
-
});
|
|
225
|
-
(0, _vitest.expect)(Object.keys(data.COLLECTED)).toHaveLength(109);
|
|
226
|
-
(0, _vitest.expect)(Object.keys(data.CALCULATED)).toHaveLength(0);
|
|
227
|
-
});
|
|
228
|
-
(0, _vitest.it)('should return calculated values', function () {
|
|
229
|
-
var data = hookRef.current.getData(true);
|
|
230
|
-
(0, _vitest.expect)(Object.keys(data.COLLECTED)).toHaveLength(109);
|
|
231
|
-
(0, _vitest.expect)(Object.keys(data.CALCULATED)).toHaveLength(33);
|
|
232
|
-
});
|
|
233
|
-
(0, _vitest.it)('should only return requested variables', function () {
|
|
234
|
-
var data = hookRef.current.getData(false, ['COMMENT']);
|
|
235
|
-
(0, _vitest.expect)(data).toMatchObject({
|
|
236
|
-
COLLECTED: {
|
|
237
|
-
COMMENT: {
|
|
238
|
-
COLLECTED: 'Mon commentaire'
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
});
|
|
242
|
-
(0, _vitest.expect)(Object.keys(data.COLLECTED)).toHaveLength(1);
|
|
243
|
-
});
|
|
244
|
-
});
|
|
245
|
-
(0, _vitest.describe)('getChangedData()', function () {
|
|
246
|
-
var hookRef;
|
|
247
|
-
(0, _vitest.beforeEach)(function () {
|
|
248
|
-
var _renderHook12 = (0, _reactHooks.renderHook)(function () {
|
|
249
|
-
return (0, _useLunatic["default"])(_source3["default"], undefined, {
|
|
250
|
-
trackChanges: true
|
|
251
|
-
});
|
|
252
|
-
}),
|
|
253
|
-
result = _renderHook12.result;
|
|
254
|
-
hookRef = result;
|
|
255
|
-
});
|
|
256
|
-
(0, _vitest.it)('should return every value', function () {
|
|
257
|
-
var data = hookRef.current.getChangedData();
|
|
258
|
-
(0, _vitest.expect)(data.COLLECTED).toEqual({});
|
|
259
|
-
});
|
|
260
|
-
(0, _vitest.it)('should return changes since the last update', function () {
|
|
261
|
-
(0, _reactHooks.act)(function () {
|
|
262
|
-
hookRef.current.onChange({
|
|
263
|
-
name: 'COMMENT'
|
|
264
|
-
}, 'Mon commentaire');
|
|
265
|
-
hookRef.current.onChange({
|
|
266
|
-
name: 'READY'
|
|
267
|
-
}, true);
|
|
268
|
-
});
|
|
269
|
-
(0, _vitest.expect)(hookRef.current.getChangedData()).toMatchObject({
|
|
270
|
-
COLLECTED: {
|
|
271
|
-
COMMENT: {
|
|
272
|
-
COLLECTED: 'Mon commentaire'
|
|
273
|
-
},
|
|
274
|
-
READY: {
|
|
275
|
-
COLLECTED: true
|
|
276
|
-
}
|
|
277
|
-
}
|
|
278
|
-
});
|
|
279
|
-
});
|
|
280
|
-
(0, _vitest.it)('should reset changes with true parameter', function () {
|
|
281
|
-
(0, _reactHooks.act)(function () {
|
|
282
|
-
hookRef.current.onChange({
|
|
283
|
-
name: 'COMMENT'
|
|
284
|
-
}, 'Mon commentaire');
|
|
285
|
-
hookRef.current.onChange({
|
|
286
|
-
name: 'READY'
|
|
287
|
-
}, true);
|
|
288
|
-
});
|
|
289
|
-
var data = hookRef.current.getChangedData(true);
|
|
290
|
-
(0, _vitest.expect)(data).toMatchObject({
|
|
291
|
-
COLLECTED: {
|
|
292
|
-
COMMENT: {
|
|
293
|
-
COLLECTED: 'Mon commentaire'
|
|
294
|
-
},
|
|
295
|
-
READY: {
|
|
296
|
-
COLLECTED: true
|
|
297
|
-
}
|
|
298
|
-
}
|
|
299
|
-
});
|
|
300
|
-
(0, _vitest.expect)(hookRef.current.getChangedData().COLLECTED).toEqual({});
|
|
301
|
-
});
|
|
302
|
-
(0, _vitest.it)('should reset changes with resetChanges()', function () {
|
|
303
|
-
(0, _reactHooks.act)(function () {
|
|
304
|
-
hookRef.current.onChange({
|
|
305
|
-
name: 'COMMENT'
|
|
306
|
-
}, 'Mon commentaire');
|
|
307
|
-
hookRef.current.onChange({
|
|
308
|
-
name: 'READY'
|
|
309
|
-
}, true);
|
|
310
|
-
});
|
|
311
|
-
hookRef.current.resetChangedData();
|
|
312
|
-
(0, _vitest.expect)(hookRef.current.getChangedData().COLLECTED).toEqual({});
|
|
313
|
-
(0, _reactHooks.act)(function () {
|
|
314
|
-
hookRef.current.onChange({
|
|
315
|
-
name: 'READY'
|
|
316
|
-
}, false);
|
|
317
|
-
});
|
|
318
|
-
(0, _vitest.expect)(hookRef.current.getChangedData().COLLECTED).toMatchObject({
|
|
319
|
-
READY: {
|
|
320
|
-
COLLECTED: false
|
|
321
|
-
}
|
|
322
|
-
});
|
|
323
|
-
});
|
|
324
|
-
});
|
|
325
228
|
});
|
|
@@ -45,7 +45,8 @@ function setStatus(status, name, state) {
|
|
|
45
45
|
function useSuggesters(_ref) {
|
|
46
46
|
var auto = _ref.auto,
|
|
47
47
|
getReferentiel = _ref.getReferentiel,
|
|
48
|
-
suggesters = _ref.suggesters
|
|
48
|
+
suggesters = _ref.suggesters,
|
|
49
|
+
workersBasePath = _ref.workersBasePath;
|
|
49
50
|
var status = (0, _react.useRef)();
|
|
50
51
|
var _useState = (0, _react.useState)(Date.now()),
|
|
51
52
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -118,7 +119,7 @@ function useSuggesters(_ref) {
|
|
|
118
119
|
return getReferentiel(name);
|
|
119
120
|
case 10:
|
|
120
121
|
data = _context.sent;
|
|
121
|
-
_createAppendTask = (0, _createAppendTask3.createAppendTask)(store, 1, nothing), _createAppendTask2 = _slicedToArray(_createAppendTask, 2), append = _createAppendTask2[0], abort = _createAppendTask2[1];
|
|
122
|
+
_createAppendTask = (0, _createAppendTask3.createAppendTask)(store, 1, nothing, workersBasePath), _createAppendTask2 = _slicedToArray(_createAppendTask, 2), append = _createAppendTask2[0], abort = _createAppendTask2[1];
|
|
122
123
|
aborts.push(abort);
|
|
123
124
|
_context.next = 15;
|
|
124
125
|
return append(data);
|
|
@@ -153,6 +154,6 @@ function useSuggesters(_ref) {
|
|
|
153
154
|
});
|
|
154
155
|
};
|
|
155
156
|
}
|
|
156
|
-
}, [suggesters, auto, getReferentiel, status]);
|
|
157
|
+
}, [suggesters, auto, getReferentiel, status, workersBasePath]);
|
|
157
158
|
return getSuggesterStatus;
|
|
158
159
|
}
|
package/lib/utils/array.js
CHANGED
|
@@ -3,20 +3,14 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.getAtIndex = getAtIndex;
|
|
7
|
-
exports.resizeArray = resizeArray;
|
|
8
6
|
exports.setAtIndex = setAtIndex;
|
|
9
7
|
exports.times = times;
|
|
10
|
-
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it["return"] != null) it["return"](); } finally { if (didErr) throw err; } } }; }
|
|
11
8
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
12
9
|
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."); }
|
|
13
|
-
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
14
|
-
function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); }
|
|
15
|
-
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."); }
|
|
16
10
|
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); }
|
|
17
|
-
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; }
|
|
18
11
|
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
19
|
-
function
|
|
12
|
+
function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
|
|
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; }
|
|
20
14
|
/**
|
|
21
15
|
* Call a callback x times
|
|
22
16
|
*/
|
|
@@ -30,55 +24,10 @@ function times(n, cb) {
|
|
|
30
24
|
* Update an item in an array without mutating the array
|
|
31
25
|
*/
|
|
32
26
|
function setAtIndex(arr, index, newValue) {
|
|
33
|
-
if (
|
|
34
|
-
|
|
27
|
+
if (index < 0) {
|
|
28
|
+
throw new Error("Cannot update value in an array, index out of bounds ".concat(index, "/").concat(arr.length));
|
|
35
29
|
}
|
|
36
|
-
var
|
|
37
|
-
|
|
38
|
-
restIndex = _index.slice(1);
|
|
39
|
-
var newArray = Array.isArray(arr) ? _toConsumableArray(arr) : [arr];
|
|
40
|
-
if (newArray.length < currentIndex + 1) {
|
|
41
|
-
newArray = resizeArray(newArray, currentIndex + 1, null);
|
|
42
|
-
}
|
|
43
|
-
newArray[currentIndex] = restIndex.length === 0 ? newValue : setAtIndex(newArray[currentIndex], restIndex, newValue);
|
|
30
|
+
var newArray = _toConsumableArray(arr);
|
|
31
|
+
newArray[index] = newValue;
|
|
44
32
|
return newArray;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Get a value inside an array
|
|
49
|
-
*/
|
|
50
|
-
function getAtIndex(arr, indexes) {
|
|
51
|
-
var current = arr;
|
|
52
|
-
if (!Array.isArray(current)) {
|
|
53
|
-
return undefined;
|
|
54
|
-
}
|
|
55
|
-
var _iterator = _createForOfIteratorHelper(indexes),
|
|
56
|
-
_step;
|
|
57
|
-
try {
|
|
58
|
-
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
59
|
-
var index = _step.value;
|
|
60
|
-
if (index < 0 || index >= current.length) {
|
|
61
|
-
return undefined; // Index out of bounds, return undefined
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
current = current[index];
|
|
65
|
-
}
|
|
66
|
-
} catch (err) {
|
|
67
|
-
_iterator.e(err);
|
|
68
|
-
} finally {
|
|
69
|
-
_iterator.f();
|
|
70
|
-
}
|
|
71
|
-
return current;
|
|
72
|
-
}
|
|
73
|
-
function resizeArray(array, newLength, defaultValue) {
|
|
74
|
-
// The value is not an array, create an empty array
|
|
75
|
-
if (!Array.isArray(array)) {
|
|
76
|
-
return new Array(newLength).fill(defaultValue !== null && defaultValue !== void 0 ? defaultValue : null);
|
|
77
|
-
}
|
|
78
|
-
if (array.length === newLength) {
|
|
79
|
-
return array;
|
|
80
|
-
}
|
|
81
|
-
return new Array(newLength).fill(defaultValue !== null && defaultValue !== void 0 ? defaultValue : null).map(function (value, index) {
|
|
82
|
-
return index < array.length ? array[index] : value;
|
|
83
|
-
}, []);
|
|
84
33
|
}
|
|
@@ -4,13 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getComponentValue = getComponentValue;
|
|
7
|
-
|
|
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
8
|
/**
|
|
9
9
|
* Extract the value associated with a component
|
|
10
10
|
* If the component expect multiple values (it has a responses property) then extract a map of values
|
|
11
11
|
*/
|
|
12
12
|
function getComponentValue(component, valueMap, rowIndex) {
|
|
13
|
-
if (
|
|
13
|
+
if (hasResponse(component)) {
|
|
14
14
|
var value = valueMap[component.response.name];
|
|
15
15
|
if (Array.isArray(value)) {
|
|
16
16
|
return value[rowIndex !== null && rowIndex !== void 0 ? rowIndex : 0];
|
|
@@ -19,7 +19,7 @@ function getComponentValue(component, valueMap, rowIndex) {
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
// For checkbox group we need to send the map of values
|
|
22
|
-
if (
|
|
22
|
+
if (hasResponses(component)) {
|
|
23
23
|
var _component$responses$, _component$responses;
|
|
24
24
|
return Object.fromEntries((_component$responses$ = (_component$responses = component.responses) === null || _component$responses === void 0 ? void 0 : _component$responses.map(function (_ref) {
|
|
25
25
|
var response = _ref.response;
|
|
@@ -31,4 +31,10 @@ function getComponentValue(component, valueMap, rowIndex) {
|
|
|
31
31
|
})) !== null && _component$responses$ !== void 0 ? _component$responses$ : []);
|
|
32
32
|
}
|
|
33
33
|
return undefined;
|
|
34
|
+
}
|
|
35
|
+
function hasResponse(component) {
|
|
36
|
+
return !!component && _typeof(component) === 'object' && 'response' in component && 'name' in component.response;
|
|
37
|
+
}
|
|
38
|
+
function hasResponses(component) {
|
|
39
|
+
return !!component && _typeof(component) === 'object' && 'responses' in component;
|
|
34
40
|
}
|
package/lib/utils/number.js
CHANGED
|
@@ -5,15 +5,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.between = between;
|
|
7
7
|
exports.forceInt = forceInt;
|
|
8
|
-
exports.isNumber = isNumber;
|
|
9
8
|
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); }
|
|
10
9
|
function forceInt(n) {
|
|
11
10
|
if (typeof n === 'string') {
|
|
12
|
-
|
|
13
|
-
if (Number.isNaN(casted)) {
|
|
14
|
-
throw new Error("Cannot cast ".concat(n, " to int"));
|
|
15
|
-
}
|
|
16
|
-
return casted;
|
|
11
|
+
return parseInt(n, 10);
|
|
17
12
|
}
|
|
18
13
|
if (typeof n === 'number') {
|
|
19
14
|
return n;
|
|
@@ -32,11 +27,4 @@ function between(n, min, max) {
|
|
|
32
27
|
return max;
|
|
33
28
|
}
|
|
34
29
|
return n;
|
|
35
|
-
}
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Check if the value is a number
|
|
39
|
-
*/
|
|
40
|
-
function isNumber(n) {
|
|
41
|
-
return typeof n === 'number' && Number.isFinite(n);
|
|
42
30
|
}
|
|
@@ -4,9 +4,9 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createAppendTask = createAppendTask;
|
|
7
|
-
var _createWorkerTs = require("../create-worker-ts");
|
|
8
|
-
var _workerPath = require("../../store-tools/worker-path");
|
|
9
7
|
var _logger = require("../../logger");
|
|
8
|
+
var _createWorkerTs = require("../create-worker-ts");
|
|
9
|
+
var _workerPath = require("../worker-path");
|
|
10
10
|
function consoleLogging() {
|
|
11
11
|
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
12
12
|
args[_key] = arguments[_key];
|
|
@@ -21,11 +21,12 @@ function consoleLogging() {
|
|
|
21
21
|
*/
|
|
22
22
|
function createAppendTask(info, version) {
|
|
23
23
|
var log = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : consoleLogging;
|
|
24
|
+
var workersBasePath = arguments.length > 3 ? arguments[3] : undefined;
|
|
24
25
|
var name = info.name,
|
|
25
26
|
fields = info.fields,
|
|
26
27
|
stopWords = info.stopWords,
|
|
27
28
|
meloto = info.meloto;
|
|
28
|
-
var worker = (0, _createWorkerTs.createWorker)((0, _workerPath.getWorkerPath)());
|
|
29
|
+
var worker = (0, _createWorkerTs.createWorker)((0, _workerPath.getWorkerPath)(_workerPath.WorkerEnum.LOADER, workersBasePath));
|
|
29
30
|
var start = false;
|
|
30
31
|
var stop = false;
|
|
31
32
|
function launch(entities) {
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.WorkerEnum = void 0;
|
|
7
|
+
exports.getWorkerPath = getWorkerPath;
|
|
8
|
+
var _package = _interopRequireDefault(require("../../../package.json"));
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
|
+
var WorkerEnum = /*#__PURE__*/function (WorkerEnum) {
|
|
11
|
+
WorkerEnum["LOADER"] = "LOADER";
|
|
12
|
+
WorkerEnum["SEARCH"] = "SEARCH";
|
|
13
|
+
WorkerEnum["LABEL"] = "LABEL";
|
|
14
|
+
return WorkerEnum;
|
|
15
|
+
}({});
|
|
16
|
+
exports.WorkerEnum = WorkerEnum;
|
|
17
|
+
var DEFAULT_BASE_PATH = 'workers';
|
|
18
|
+
var WORKER_PATH = {
|
|
19
|
+
LOADER: "lunatic-append-worker-".concat(_package["default"].workersVersion, ".js"),
|
|
20
|
+
SEARCH: "lunatic-searching-worker-".concat(_package["default"].workersVersion, ".js"),
|
|
21
|
+
LABEL: "lunatic-label-worker-".concat(_package["default"].workersVersion, ".js")
|
|
22
|
+
};
|
|
23
|
+
function getWorkerPath(workerType, workersBasePath) {
|
|
24
|
+
if (workersBasePath) {
|
|
25
|
+
return "".concat(workersBasePath, "/").concat(WORKER_PATH[workerType]);
|
|
26
|
+
} else {
|
|
27
|
+
return "".concat(DEFAULT_BASE_PATH, "/").concat(WORKER_PATH[workerType]);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = void 0;
|
|
7
|
+
/**
|
|
8
|
+
* Convert the value into something compatible with VTL
|
|
9
|
+
*/
|
|
10
|
+
function getVtlCompatibleValue(value) {
|
|
11
|
+
if (value === undefined) {
|
|
12
|
+
return null;
|
|
13
|
+
}
|
|
14
|
+
if (Array.isArray(value)) {
|
|
15
|
+
return {
|
|
16
|
+
dataStructure: {
|
|
17
|
+
result: {}
|
|
18
|
+
},
|
|
19
|
+
dataPoints: {
|
|
20
|
+
result: value
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
return value;
|
|
25
|
+
}
|
|
26
|
+
var _default = getVtlCompatibleValue;
|
|
27
|
+
exports["default"] = _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
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 _datasetBuilder["default"];
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _datasetBuilder = _interopRequireDefault(require("./dataset-builder"));
|
|
13
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inseefr/lunatic",
|
|
3
|
-
"version": "2.6.3
|
|
4
|
-
"workersVersion": "0.
|
|
3
|
+
"version": "2.6.3",
|
|
4
|
+
"workersVersion": "0.3.0-experimental",
|
|
5
5
|
"description": "Library of questionnaire components",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -26,7 +26,10 @@
|
|
|
26
26
|
"main": "lib/index.js",
|
|
27
27
|
"types": "lib/src/index.d.ts",
|
|
28
28
|
"files": [
|
|
29
|
-
"lib"
|
|
29
|
+
"lib",
|
|
30
|
+
"workers-release",
|
|
31
|
+
"scripts/build/workers-paths.js",
|
|
32
|
+
"scripts/build/add-workers-to-public.js"
|
|
30
33
|
],
|
|
31
34
|
"scripts": {
|
|
32
35
|
"test": "vitest run",
|
|
@@ -42,13 +45,15 @@
|
|
|
42
45
|
"format": "npm run _format -- --write",
|
|
43
46
|
"format:check": "npm run _format -- --list-different",
|
|
44
47
|
"test-coverage": "vitest run --coverage",
|
|
45
|
-
"build": "
|
|
46
|
-
"build
|
|
47
|
-
"
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"storybook": "
|
|
51
|
-
|
|
48
|
+
"build-workers": "node ./scripts/build/build-workers.js",
|
|
49
|
+
"build": "babel src --out-dir lib --extensions \".ts,.js,.tsx,.jsx\" --copy-files && tsc --project tsconfig.prod.json && npm run build-workers",
|
|
50
|
+
"prepare-workers": "npm run build-workers && node ./scripts/build/add-workers-to-public.js",
|
|
51
|
+
"postinstall": "node ./scripts/build/add-workers-to-public.js",
|
|
52
|
+
"storybook": "npm run prepare-workers && start-storybook -p 9999 -s ./public",
|
|
53
|
+
"build-storybook": "npm run prepare-workers && build-storybook"
|
|
54
|
+
},
|
|
55
|
+
"bin": {
|
|
56
|
+
"workers": "./scripts/build/add-workers-to-public.js"
|
|
52
57
|
},
|
|
53
58
|
"keywords": [
|
|
54
59
|
"react",
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
const fs = require('fs');
|
|
3
|
+
const path = require('path');
|
|
4
|
+
const { currentPublicFolder, workersPath } = require('./workers-paths');
|
|
5
|
+
|
|
6
|
+
const currentPackageJson = require(path.resolve(
|
|
7
|
+
`${process.cwd()}/package.json`
|
|
8
|
+
));
|
|
9
|
+
const lunaticPackageJson = require('../../package.json');
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Copy worker only if not exists
|
|
13
|
+
*/
|
|
14
|
+
const copyWorkerToPublicFolder = () => {
|
|
15
|
+
console.log('Running add-workers-to-public....');
|
|
16
|
+
|
|
17
|
+
if (!fs.existsSync(currentPublicFolder)) {
|
|
18
|
+
fs.mkdirSync(currentPublicFolder, { recursive: true });
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
Object.keys(workersPath).forEach((worker) => {
|
|
22
|
+
const { name, source, dest } = workersPath[worker];
|
|
23
|
+
const isWorkerExists = fs.existsSync(dest);
|
|
24
|
+
|
|
25
|
+
if (!isWorkerExists) {
|
|
26
|
+
console.log(`Copy : ${name} to ${currentPublicFolder}`);
|
|
27
|
+
fs.copyFileSync(source, dest);
|
|
28
|
+
} else {
|
|
29
|
+
console.log(`${name} is already in ${currentPublicFolder} -> Skipped`);
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
const isLunaticPostInstall = () => {
|
|
35
|
+
const lunaticName = lunaticPackageJson.name;
|
|
36
|
+
const currentName = currentPackageJson.name;
|
|
37
|
+
|
|
38
|
+
const currentNpmLiveCycle = process.env.npm_lifecycle_event;
|
|
39
|
+
return lunaticName === currentName && currentNpmLiveCycle === 'postinstall';
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
if (isLunaticPostInstall()) {
|
|
43
|
+
console.log('PostInstall skipped !');
|
|
44
|
+
} else copyWorkerToPublicFolder();
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
var PACKAGE = require('../../package.json');
|
|
2
|
+
const path = require('path');
|
|
3
|
+
|
|
4
|
+
var version = PACKAGE.workersVersion;
|
|
5
|
+
|
|
6
|
+
const currentPublicFolder = path.resolve(`${process.cwd()}/public/workers`);
|
|
7
|
+
const workersReleaseFolder = path.resolve(__dirname, '../../workers-release');
|
|
8
|
+
|
|
9
|
+
const workersPath = {
|
|
10
|
+
append: {
|
|
11
|
+
name: 'Append worker',
|
|
12
|
+
source: `${workersReleaseFolder}/lunatic-append-worker-${version}.js`,
|
|
13
|
+
dest: `${currentPublicFolder}/lunatic-append-worker-${version}.js`,
|
|
14
|
+
webpack: {
|
|
15
|
+
entry: './src/utils/suggester-workers/append-to-index/append.worker.js',
|
|
16
|
+
filename: `lunatic-append-worker-${version}.js`,
|
|
17
|
+
},
|
|
18
|
+
},
|
|
19
|
+
label: {
|
|
20
|
+
name: 'Label worker',
|
|
21
|
+
source: `${workersReleaseFolder}/lunatic-label-worker-${version}.js`,
|
|
22
|
+
dest: `${currentPublicFolder}/lunatic-label-worker-${version}.js`,
|
|
23
|
+
webpack: {
|
|
24
|
+
entry:
|
|
25
|
+
'./src/utils/suggester-workers/find-best-label/find-best-label.worker.js',
|
|
26
|
+
filename: `lunatic-label-worker-${version}.js`,
|
|
27
|
+
},
|
|
28
|
+
},
|
|
29
|
+
searching: {
|
|
30
|
+
name: 'Searching worker',
|
|
31
|
+
source: `${workersReleaseFolder}/lunatic-searching-worker-${version}.js`,
|
|
32
|
+
dest: `${currentPublicFolder}/lunatic-searching-worker-${version}.js`,
|
|
33
|
+
webpack: {
|
|
34
|
+
entry: './src/utils/suggester-workers/searching/searching.worker.js',
|
|
35
|
+
filename: `lunatic-searching-worker-${version}.js`,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
module.exports = {
|
|
41
|
+
currentPublicFolder: currentPublicFolder,
|
|
42
|
+
workersReleaseFolder: workersReleaseFolder,
|
|
43
|
+
workersPath: workersPath,
|
|
44
|
+
};
|