@inseefr/lunatic 2.6.2 → 2.6.3-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/lib/components/index.js +4 -4
- package/lib/components/loop/block-for-loop.js +6 -10
- package/lib/components/loop/roster-for-loop/roster-for-loop.js +27 -35
- package/lib/components/lunatic-components.js +16 -5
- package/lib/components/pairwise-links/pairwise-links.js +27 -30
- package/lib/components/table/lunatic-table.js +22 -13
- package/lib/components/table/{header.js → table-header.js} +3 -5
- package/lib/hooks/use-track-changes.js +50 -0
- 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/use-lunatic/actions.js +3 -3
- package/lib/use-lunatic/commons/compile-controls.js +3 -5
- package/lib/use-lunatic/commons/component.js +22 -0
- package/lib/use-lunatic/commons/execute-condition-filter.js +1 -9
- package/lib/use-lunatic/commons/fill-components/fill-component-expressions.js +2 -3
- package/lib/use-lunatic/commons/fill-components/fill-component-value.js +21 -7
- package/lib/use-lunatic/commons/fill-components/fill-components.js +5 -3
- package/lib/use-lunatic/commons/{execute-expression/get-safety-expression.js → fill-components/fill-iterations.js} +30 -20
- package/lib/use-lunatic/commons/fill-components/fill-missing-response.js +6 -13
- package/lib/use-lunatic/commons/fill-components/fill-specific-expression.js +58 -5
- package/lib/use-lunatic/commons/get-compatible-vtl-expression.js +1 -0
- package/lib/use-lunatic/commons/index.js +0 -21
- 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/{reducer/reduce-handle-change/reduce-variables-array.js → commons/variables/get-questionnaire-data.js} +53 -32
- package/lib/use-lunatic/commons/variables/lunatic-variables-store.js +330 -0
- package/lib/use-lunatic/commons/variables/lunatic-variables-store.spec.js +216 -0
- package/lib/use-lunatic/initial-state.js +5 -2
- package/lib/use-lunatic/reducer/overview/overview-on-change.js +1 -1
- package/lib/use-lunatic/reducer/{reduce-handle-change/reduce-variables-simple.js → reduce-handle-change.js} +15 -14
- package/lib/use-lunatic/reducer/reduce-on-init.js +89 -181
- package/lib/use-lunatic/reducer/reducer.js +2 -2
- package/lib/use-lunatic/reducer/resolve-component-controls/resolve-simple-control.js +2 -4
- package/lib/use-lunatic/use-lunatic.js +18 -14
- package/lib/use-lunatic/use-lunatic.test.js +131 -2
- package/lib/utils/array.js +57 -6
- package/lib/utils/array.spec.js +30 -0
- package/lib/utils/env.js +10 -0
- package/lib/utils/get-component-value.js +3 -9
- package/lib/utils/number.js +13 -1
- package/lib/utils/variables.js +37 -0
- package/lib/utils/vtl.js +100 -0
- package/package.json +1 -1
- 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/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/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-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
|
@@ -10,14 +10,15 @@ var actions = _interopRequireWildcard(require("./actions"));
|
|
|
10
10
|
var _commons = require("./commons");
|
|
11
11
|
var _i18n = _interopRequireDefault(require("../i18n"));
|
|
12
12
|
var _constants = require("../utils/constants");
|
|
13
|
-
var _getData = require("./commons/get-data");
|
|
14
13
|
var _initialState = _interopRequireDefault(require("./initial-state"));
|
|
15
14
|
var _lunaticContext = require("./lunatic-context");
|
|
16
|
-
var _compileControls =
|
|
15
|
+
var _compileControls = require("./commons/compile-controls");
|
|
17
16
|
var _getOverview = require("./commons/getOverview");
|
|
18
17
|
var _useLoopVariables = require("./hooks/use-loop-variables");
|
|
19
18
|
var _reducer = _interopRequireDefault(require("./reducer"));
|
|
20
19
|
var _useSuggesters = require("./use-suggesters");
|
|
20
|
+
var _getQuestionnaireData = require("./commons/variables/get-questionnaire-data");
|
|
21
|
+
var _useTrackChanges2 = require("../hooks/use-track-changes");
|
|
21
22
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
22
23
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
24
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
@@ -76,7 +77,9 @@ function useLunatic(source) {
|
|
|
76
77
|
_ref$dontKnowButton = _ref.dontKnowButton,
|
|
77
78
|
dontKnowButton = _ref$dontKnowButton === void 0 ? DEFAULT_DONT_KNOW : _ref$dontKnowButton,
|
|
78
79
|
_ref$refusedButton = _ref.refusedButton,
|
|
79
|
-
refusedButton = _ref$refusedButton === void 0 ? DEFAULT_REFUSED : _ref$refusedButton
|
|
80
|
+
refusedButton = _ref$refusedButton === void 0 ? DEFAULT_REFUSED : _ref$refusedButton,
|
|
81
|
+
_ref$trackChanges = _ref.trackChanges,
|
|
82
|
+
trackChanges = _ref$trackChanges === void 0 ? false : _ref$trackChanges;
|
|
80
83
|
var _useReducer = (0, _react.useReducer)(_reducer["default"], _initialState["default"]),
|
|
81
84
|
_useReducer2 = _slicedToArray(_useReducer, 2),
|
|
82
85
|
state = _useReducer2[0],
|
|
@@ -109,7 +112,7 @@ function useLunatic(source) {
|
|
|
109
112
|
suggesters: suggesters
|
|
110
113
|
});
|
|
111
114
|
var compileControls = (0, _react.useCallback)(function () {
|
|
112
|
-
return (0, _compileControls
|
|
115
|
+
return (0, _compileControls.compileControls)({
|
|
113
116
|
pager: pager,
|
|
114
117
|
pages: pages,
|
|
115
118
|
isInLoop: isInLoop,
|
|
@@ -146,18 +149,17 @@ function useLunatic(source) {
|
|
|
146
149
|
return components;
|
|
147
150
|
}, [components]);
|
|
148
151
|
var handleChange = (0, _react.useCallback)(function (response, value, args) {
|
|
149
|
-
dispatch(actions.handleChange(typeof response === 'string' ?
|
|
150
|
-
name: response
|
|
151
|
-
} : response, value, args));
|
|
152
|
+
dispatch(actions.handleChange(typeof response === 'string' ? response : response.name, value, args === null || args === void 0 ? void 0 : args.iteration));
|
|
152
153
|
onChange(response, value, args);
|
|
153
154
|
}, [dispatch, onChange]);
|
|
154
|
-
var getData = function getData(withRefreshedCalculated) {
|
|
155
|
-
|
|
156
|
-
return (0, _getData.getQuestionnaireData)({
|
|
157
|
-
variables: variables,
|
|
158
|
-
withRefreshedCalculated: withRefreshedCalculated
|
|
159
|
-
});
|
|
155
|
+
var getData = function getData(withRefreshedCalculated, variableNames) {
|
|
156
|
+
return (0, _getQuestionnaireData.getQuestionnaireData)(state.variables, source.variables, withRefreshedCalculated, variableNames);
|
|
160
157
|
};
|
|
158
|
+
var _useTrackChanges = (0, _useTrackChanges2.useTrackChanges)(trackChanges, state.variables, function (variableNames) {
|
|
159
|
+
return getData(false, variableNames);
|
|
160
|
+
}),
|
|
161
|
+
resetChangedData = _useTrackChanges.resetChangedData,
|
|
162
|
+
getChangedData = _useTrackChanges.getChangedData;
|
|
161
163
|
var buildedOverview = (0, _react.useMemo)(function () {
|
|
162
164
|
return (0, _getOverview.overviewWithChildren)(overview);
|
|
163
165
|
}, [overview]);
|
|
@@ -204,7 +206,9 @@ function useLunatic(source) {
|
|
|
204
206
|
Provider: Provider,
|
|
205
207
|
onChange: handleChange,
|
|
206
208
|
overview: buildedOverview,
|
|
207
|
-
loopVariables: (0, _useLoopVariables.useLoopVariables)(pager, state.pages)
|
|
209
|
+
loopVariables: (0, _useLoopVariables.useLoopVariables)(pager, state.pages),
|
|
210
|
+
getChangedData: getChangedData,
|
|
211
|
+
resetChangedData: resetChangedData
|
|
208
212
|
};
|
|
209
213
|
}
|
|
210
214
|
var _default = useLunatic;
|
|
@@ -5,7 +5,7 @@ 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/questionnaires2023/simpsons/source.json"));
|
|
9
9
|
var _source4 = _interopRequireDefault(require("../stories/component-set/source.json"));
|
|
10
10
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
11
11
|
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); }
|
|
@@ -38,7 +38,7 @@ var dataFromObject = function dataFromObject(o) {
|
|
|
38
38
|
result = _renderHook.result;
|
|
39
39
|
(0, _vitest.expect)(result.current.pager.page).toBe('1');
|
|
40
40
|
(0, _vitest.expect)(result.current.pager.lastReachedPage).toBe('1');
|
|
41
|
-
(0, _vitest.expect)(result.current.pager.maxPage).toBe('
|
|
41
|
+
(0, _vitest.expect)(result.current.pager.maxPage).toBe('41');
|
|
42
42
|
});
|
|
43
43
|
(0, _vitest.it)('should go to the next page correcly', function () {
|
|
44
44
|
var _renderHook2 = (0, _reactHooks.renderHook)(function () {
|
|
@@ -193,4 +193,133 @@ var dataFromObject = function dataFromObject(o) {
|
|
|
193
193
|
});
|
|
194
194
|
});
|
|
195
195
|
});
|
|
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
|
+
});
|
|
196
325
|
});
|
package/lib/utils/array.js
CHANGED
|
@@ -3,14 +3,20 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
+
exports.getAtIndex = getAtIndex;
|
|
7
|
+
exports.resizeArray = resizeArray;
|
|
6
8
|
exports.setAtIndex = setAtIndex;
|
|
7
9
|
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; } } }; }
|
|
8
11
|
function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
|
|
9
12
|
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."); }
|
|
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); }
|
|
11
|
-
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
12
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
|
+
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
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
|
+
function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
|
|
19
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
14
20
|
/**
|
|
15
21
|
* Call a callback x times
|
|
16
22
|
*/
|
|
@@ -24,10 +30,55 @@ function times(n, cb) {
|
|
|
24
30
|
* Update an item in an array without mutating the array
|
|
25
31
|
*/
|
|
26
32
|
function setAtIndex(arr, index, newValue) {
|
|
27
|
-
if (index
|
|
28
|
-
|
|
33
|
+
if (!Array.isArray(index)) {
|
|
34
|
+
return setAtIndex(arr, [index], newValue);
|
|
29
35
|
}
|
|
30
|
-
var
|
|
31
|
-
|
|
36
|
+
var _index = _toArray(index),
|
|
37
|
+
currentIndex = _index[0],
|
|
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);
|
|
32
44
|
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
|
+
}, []);
|
|
33
84
|
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _vitest = require("vitest");
|
|
4
|
+
var _array = require("./array");
|
|
5
|
+
(0, _vitest.describe)('array', function () {
|
|
6
|
+
(0, _vitest.describe)('resizeArray()', function () {
|
|
7
|
+
(0, _vitest.it)('should append new value', function () {
|
|
8
|
+
(0, _vitest.expect)((0, _array.resizeArray)([1, 2], 3, 3)).toEqual([1, 2, 3]);
|
|
9
|
+
(0, _vitest.expect)((0, _array.resizeArray)([1, 2], 4, 3)).toEqual([1, 2, 3, 3]);
|
|
10
|
+
});
|
|
11
|
+
(0, _vitest.it)('should remove value', function () {
|
|
12
|
+
(0, _vitest.expect)((0, _array.resizeArray)([1, 2, 3], 1)).toEqual([1]);
|
|
13
|
+
});
|
|
14
|
+
});
|
|
15
|
+
(0, _vitest.describe)('setAtIndex', function () {
|
|
16
|
+
(0, _vitest.it)('should work with simple index', function () {
|
|
17
|
+
(0, _vitest.expect)((0, _array.setAtIndex)([1, 2, 3], 1, 3)).toEqual([1, 3, 3]);
|
|
18
|
+
});
|
|
19
|
+
(0, _vitest.it)('should work with non array value', function () {
|
|
20
|
+
(0, _vitest.expect)((0, _array.setAtIndex)(null, 1, 3)).toEqual([null, 3]);
|
|
21
|
+
(0, _vitest.expect)((0, _array.setAtIndex)(4, 1, 3)).toEqual([4, 3]);
|
|
22
|
+
});
|
|
23
|
+
(0, _vitest.it)('should work with deep index', function () {
|
|
24
|
+
(0, _vitest.expect)((0, _array.setAtIndex)([[1, 2, 3], [1, 2, 3], [1, 2, 3]], [1, 2], 10)).toEqual([[1, 2, 3], [1, 2, 10], [1, 2, 3]]);
|
|
25
|
+
});
|
|
26
|
+
(0, _vitest.it)('should work with deep and non array value', function () {
|
|
27
|
+
(0, _vitest.expect)((0, _array.setAtIndex)([null], [1, 2], 10)).toEqual([null, [null, null, 10]]);
|
|
28
|
+
});
|
|
29
|
+
});
|
|
30
|
+
});
|
package/lib/utils/env.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.isTestEnv = isTestEnv;
|
|
7
|
+
function isTestEnv() {
|
|
8
|
+
var meta = import.meta;
|
|
9
|
+
return meta && meta !== null && meta !== void 0 && meta.env ? import.meta.env.MODE === 'test' : false;
|
|
10
|
+
}
|
|
@@ -4,13 +4,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.getComponentValue = getComponentValue;
|
|
7
|
-
|
|
7
|
+
var _component = require("../use-lunatic/commons/component");
|
|
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 (hasResponse(component)) {
|
|
13
|
+
if ((0, _component.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 (hasResponses(component)) {
|
|
22
|
+
if ((0, _component.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,10 +31,4 @@ 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;
|
|
40
34
|
}
|
package/lib/utils/number.js
CHANGED
|
@@ -5,10 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.between = between;
|
|
7
7
|
exports.forceInt = forceInt;
|
|
8
|
+
exports.isNumber = isNumber;
|
|
8
9
|
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); }
|
|
9
10
|
function forceInt(n) {
|
|
10
11
|
if (typeof n === 'string') {
|
|
11
|
-
|
|
12
|
+
var casted = parseInt(n, 10);
|
|
13
|
+
if (Number.isNaN(casted)) {
|
|
14
|
+
throw new Error("Cannot cast ".concat(n, " to int"));
|
|
15
|
+
}
|
|
16
|
+
return casted;
|
|
12
17
|
}
|
|
13
18
|
if (typeof n === 'number') {
|
|
14
19
|
return n;
|
|
@@ -27,4 +32,11 @@ function between(n, min, max) {
|
|
|
27
32
|
return max;
|
|
28
33
|
}
|
|
29
34
|
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);
|
|
30
42
|
}
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getInitialVariableValue = getInitialVariableValue;
|
|
7
|
+
/**
|
|
8
|
+
* Extract the initial value from the source.json and data.json
|
|
9
|
+
*/
|
|
10
|
+
function getInitialVariableValue(variable) {
|
|
11
|
+
var _data$variable$variab;
|
|
12
|
+
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
13
|
+
switch (variable.variableType) {
|
|
14
|
+
case 'EXTERNAL':
|
|
15
|
+
case 'CALCULATED':
|
|
16
|
+
return (_data$variable$variab = data[variable.variableType]) === null || _data$variable$variab === void 0 ? void 0 : _data$variable$variab[variable.name];
|
|
17
|
+
case 'COLLECTED':
|
|
18
|
+
var collectedData = data.COLLECTED;
|
|
19
|
+
var fromData;
|
|
20
|
+
if (collectedData && variable.name in collectedData) {
|
|
21
|
+
var _collectedData$variab = collectedData[variable.name],
|
|
22
|
+
COLLECTED = _collectedData$variab.COLLECTED,
|
|
23
|
+
FORCED = _collectedData$variab.FORCED;
|
|
24
|
+
fromData = COLLECTED !== null && COLLECTED !== void 0 ? COLLECTED : FORCED;
|
|
25
|
+
}
|
|
26
|
+
if ('values' in variable && variable.values) {
|
|
27
|
+
var _ref, _fromData;
|
|
28
|
+
var _variable$values = variable.values,
|
|
29
|
+
_COLLECTED = _variable$values.COLLECTED,
|
|
30
|
+
_FORCED = _variable$values.FORCED;
|
|
31
|
+
return (_ref = (_fromData = fromData) !== null && _fromData !== void 0 ? _fromData : _FORCED) !== null && _ref !== void 0 ? _ref : _COLLECTED;
|
|
32
|
+
}
|
|
33
|
+
return undefined;
|
|
34
|
+
default:
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
}
|
package/lib/utils/vtl.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.getExpressionAsString = getExpressionAsString;
|
|
7
|
+
exports.getExpressionType = getExpressionType;
|
|
8
|
+
exports.getVTLCompatibleValue = getVTLCompatibleValue;
|
|
9
|
+
exports.interpretVTL = interpretVTL;
|
|
10
|
+
exports.parseVTLVariables = parseVTLVariables;
|
|
11
|
+
var _object = require("./object");
|
|
12
|
+
var _trevas = require("@inseefr/trevas");
|
|
13
|
+
var _antlr = _interopRequireDefault(require("antlr4"));
|
|
14
|
+
var _vtl = require("@inseefr/vtl-2.0-antlr-tools");
|
|
15
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
16
|
+
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); }
|
|
17
|
+
/**
|
|
18
|
+
* Simplified version of interpret (that converts binding and value)
|
|
19
|
+
*/
|
|
20
|
+
function interpretVTL(expression, bindings) {
|
|
21
|
+
var result = (0, _trevas.interpret)(expression, (0, _object.objectMap)(bindings, function (k, v) {
|
|
22
|
+
return [k, getVTLCompatibleValue(v)];
|
|
23
|
+
}));
|
|
24
|
+
if (isDataSet(result)) {
|
|
25
|
+
return extractDataSetResult(result);
|
|
26
|
+
}
|
|
27
|
+
return result;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
* Extract variables used in a VTL expression
|
|
32
|
+
*/
|
|
33
|
+
function parseVTLVariables(expression) {
|
|
34
|
+
try {
|
|
35
|
+
var chars = new _antlr["default"].InputStream(expression);
|
|
36
|
+
var lexer = new _vtl.VtlLexer(chars);
|
|
37
|
+
var dependencySet = lexer.getAllTokens().reduce(function (acc, _ref) {
|
|
38
|
+
var start = _ref.start,
|
|
39
|
+
stop = _ref.stop,
|
|
40
|
+
type = _ref.type;
|
|
41
|
+
if (type === 234) {
|
|
42
|
+
acc.add(expression.substring(start, stop + 1));
|
|
43
|
+
}
|
|
44
|
+
return acc;
|
|
45
|
+
}, new Set());
|
|
46
|
+
dependencySet["delete"](expression); // Prevent dependency loop
|
|
47
|
+
return Array.from(dependencySet);
|
|
48
|
+
} catch (e) {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/**
|
|
54
|
+
* Transform a value to make it compatible with VTL (for bindings)
|
|
55
|
+
*/
|
|
56
|
+
function getVTLCompatibleValue(value) {
|
|
57
|
+
if (value === undefined) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
if (Array.isArray(value)) {
|
|
61
|
+
return {
|
|
62
|
+
dataStructure: {
|
|
63
|
+
result: {}
|
|
64
|
+
},
|
|
65
|
+
dataPoints: {
|
|
66
|
+
result: value
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
return value;
|
|
71
|
+
}
|
|
72
|
+
function getExpressionType(expression) {
|
|
73
|
+
if (typeof expression === 'string') {
|
|
74
|
+
return 'VTL';
|
|
75
|
+
}
|
|
76
|
+
if (expression && _typeof(expression) === 'object' && 'type' in expression && typeof expression.type === 'string') {
|
|
77
|
+
return expression.type;
|
|
78
|
+
}
|
|
79
|
+
return '';
|
|
80
|
+
}
|
|
81
|
+
function getExpressionAsString(expression) {
|
|
82
|
+
if (typeof expression === 'string') {
|
|
83
|
+
return expression;
|
|
84
|
+
}
|
|
85
|
+
if (expression && _typeof(expression) === 'object' && 'value' in expression && typeof expression.value === 'string') {
|
|
86
|
+
return expression.value;
|
|
87
|
+
}
|
|
88
|
+
return '';
|
|
89
|
+
}
|
|
90
|
+
function isDataSet(result) {
|
|
91
|
+
return _typeof(result) === 'object' && result !== null && 'dataPoints' in result && result.dataPoints !== null && _typeof(result.dataPoints) === 'object' && 'result' in result.dataPoints;
|
|
92
|
+
}
|
|
93
|
+
function extractDataSetResult(dataSet) {
|
|
94
|
+
var dataPoints = dataSet.dataPoints;
|
|
95
|
+
if (dataPoints) {
|
|
96
|
+
var result = dataPoints.result;
|
|
97
|
+
return result;
|
|
98
|
+
}
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
package/package.json
CHANGED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.getInitialNbRows = getInitialNbRows;
|
|
7
|
-
/**
|
|
8
|
-
* Find the length of the variable (the biggest value sent to the loop)
|
|
9
|
-
*/
|
|
10
|
-
function getInitialNbRows(value) {
|
|
11
|
-
return Object.values(value).reduce(function (length, variable) {
|
|
12
|
-
if (Array.isArray(variable)) {
|
|
13
|
-
return Math.max(length, variable.length);
|
|
14
|
-
}
|
|
15
|
-
return length;
|
|
16
|
-
}, 1);
|
|
17
|
-
}
|
|
@@ -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 _pairwiseLinks["default"];
|
|
10
|
-
}
|
|
11
|
-
});
|
|
12
|
-
var _pairwiseLinks = _interopRequireDefault(require("./pairwise-links"));
|
|
13
|
-
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|