@inseefr/lunatic 2.4.1 → 2.4.2
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/commons/components/lunatic-component-with-label.js +5 -6
- package/lib/components/component-set/html/component-set-component-container.js +20 -0
- package/lib/components/component-set/html/component-set-components.js +59 -0
- package/lib/components/component-set/html/component-set.js +32 -0
- package/lib/components/component-set/html/legend/index.js +13 -0
- package/lib/components/component-set/html/legend/legend.js +31 -0
- package/lib/components/component-set/index.js +20 -0
- package/lib/components/component-set/lunatic-component-set.js +69 -0
- package/lib/components/components.js +9 -1
- package/lib/components/declarations/declarations.scss +8 -2
- package/lib/components/input/html/input.scss +1 -1
- package/lib/components/radio/html/radio-group-content.js +4 -2
- package/lib/components/radio/html/radio-group-content.spec.js +14 -0
- package/lib/components/radio/html/radio-group.js +8 -4
- package/lib/components/radio/html/radio-option.js +14 -10
- package/lib/components/radio/lunatic-radio-group.js +6 -3
- package/lib/components/radio/radio-group.js +5 -2
- package/lib/components/suggester/html/suggester.js +2 -1
- package/lib/i18n/dictionary.js +4 -0
- package/lib/src/i18n/dictionary.d.ts +4 -0
- package/lib/src/i18n/index.d.ts +1 -1
- package/lib/src/use-lunatic/commons/execute-expression/create-refresh-calculated.d.ts +2 -2
- package/lib/src/use-lunatic/commons/execute-expression/create-refresh-calculated.spec.d.ts +1 -0
- package/lib/src/use-lunatic/commons/fill-components/fill-component-expressions.d.ts +1 -1
- package/lib/src/use-lunatic/commons/fill-components/fill-from-state.d.ts +39 -0
- package/lib/src/use-lunatic/commons/fill-components/fill-specific-expression.d.ts +30 -0
- package/lib/src/use-lunatic/commons/use-components-from-state.d.ts +1 -1
- package/lib/src/use-lunatic/reducer/commons/is-loop-component.d.ts +2 -2
- package/lib/src/use-lunatic/reducer/resolve-component-controls/index.d.ts +1 -0
- package/lib/src/use-lunatic/reducer/resolve-component-controls/resolve-roundabout-control.d.ts +10 -0
- package/lib/src/use-lunatic/reducer/resolve-component-controls/resolve-simple-control.d.ts +3 -0
- package/lib/src/use-lunatic/replace-component-sequence.d.ts +9 -0
- package/lib/src/use-lunatic/type-source.d.ts +14 -3
- package/lib/src/use-lunatic/use-lunatic.d.ts +1 -1
- package/lib/src/utils/suggester-workers/commons-tokenizer/prepare-string-indexation.d.ts +2 -0
- package/lib/src/utils/suggester-workers/searching/compute-score.d.ts +3 -0
- package/lib/src/utils/suggester-workers/searching/meloto-order.d.ts +24 -0
- package/lib/stories/Introduction.stories.mdx +4 -4
- package/lib/stories/checkboxGroup/source.json +4 -5
- package/lib/stories/component-set/component-set.stories.js +56 -0
- package/lib/stories/component-set/data.json +18 -0
- package/lib/stories/component-set/data1.json +18 -0
- package/lib/stories/component-set/data2.json +18 -0
- package/lib/stories/component-set/source.json +99 -0
- package/lib/stories/component-set/source1.json +287 -0
- package/lib/stories/component-set/source2.json +413 -0
- package/lib/stories/custom-mui/suggester-mui/suggester-mui.js +1 -2
- package/lib/stories/declaration/source.json +24 -0
- package/lib/stories/loop/paginated-loop.stories.js +34 -0
- package/lib/stories/loop/source-paginated.json +126 -0
- package/lib/stories/paste-questionnaire/test.stories.js +1 -1
- package/lib/stories/questionnaires-test/controls/controls-externes.json +75 -0
- package/lib/stories/questionnaires-test/controls/controls-externes.stories.js +62 -0
- package/lib/stories/questionnaires-test/controls/controls.stories.js +1 -1
- package/lib/stories/questionnaires-test/test.stories.js +1 -1
- package/lib/stories/questionnaires2023/bySequence/source.json +5054 -0
- package/lib/stories/questionnaires2023/bySequence/ticWeb.stories.js +64 -0
- package/lib/stories/questionnaires2023/famille/famille.stories.js +64 -0
- package/lib/stories/questionnaires2023/famille/source.json +50344 -0
- package/lib/stories/questionnaires2023/simpsons/simpsons.stories.js +64 -0
- package/lib/stories/questionnaires2023/simpsons/source.json +5176 -0
- package/lib/stories/questionnaires2023/ticTel/source.json +12888 -0
- package/lib/stories/questionnaires2023/ticTel/ticWeb.stories.js +64 -0
- package/lib/stories/questionnaires2023/ticWeb/source.json +11331 -0
- package/lib/stories/questionnaires2023/ticWeb/ticWeb.stories.js +64 -0
- package/lib/stories/resizing-questionnaire/source.json +789 -0
- package/lib/stories/resizing-questionnaire/test.stories.js +84 -0
- package/lib/stories/roundabout/source.json +16 -0
- package/lib/stories/suggester/SuggesterNotification.js +26 -0
- package/lib/stories/suggester/suggester-workers.stories.js +8 -5
- package/lib/stories/suggester/suggester.stories.js +1 -0
- package/lib/use-lunatic/actions.js +4 -4
- package/lib/use-lunatic/commons/calculated-variables.js +1 -1
- package/lib/use-lunatic/commons/compile-controls.js +4 -3
- package/lib/use-lunatic/commons/execute-expression/create-execute-expression.spec.js +155 -0
- package/lib/use-lunatic/commons/execute-expression/create-refresh-calculated.js +3 -2
- package/lib/use-lunatic/commons/execute-expression/create-refresh-calculated.spec.js +128 -0
- package/lib/use-lunatic/commons/fill-components/fill-component-expressions.js +4 -1
- package/lib/use-lunatic/reducer/reduce-on-init.js +1 -2
- package/lib/use-lunatic/reducer/resolve-component-controls/index.js +12 -0
- package/lib/use-lunatic/reducer/{validate-controls/validation-utils.js → resolve-component-controls/resolve-component-control.js} +10 -34
- package/lib/use-lunatic/reducer/resolve-component-controls/resolve-roundabout-control.js +54 -0
- package/lib/use-lunatic/reducer/resolve-component-controls/resolve-simple-control.js +44 -0
- package/lib/use-lunatic/replace-component-sequence.js +28 -0
- package/lib/use-lunatic/type-source.js +15 -9
- package/lib/use-lunatic/use-lunatic.js +1 -1
- package/lib/use-lunatic/use-suggesters.js +5 -5
- package/lib/utils/suggester-workers/append-to-index/create-append-task.js +4 -2
- package/lib/utils/suggester-workers/append-to-index/dist/create-append-task.js +4 -2
- package/lib/utils/suggester-workers/commons-tokenizer/get-stemmer.spec.js +11 -0
- package/lib/utils/suggester-workers/commons-tokenizer/prepare-string-indexation.spec.js +10 -0
- package/lib/utils/suggester-workers/searching/compute-score.js +7 -12
- package/lib/utils/suggester-workers/searching/meloto-order.js +53 -0
- package/lib/utils/suggester-workers/searching/meloto-order.spec.js +67 -0
- package/lib/utils/suggester-workers/searching/searching.js +3 -3
- package/lib/utils/suggester-workers/searching/searching.worker.js +4 -2
- package/package.json +1 -1
- /package/lib/src/use-lunatic/reducer/{validate-controls/validation-utils.d.ts → resolve-component-controls/resolve-component-control.d.ts} +0 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = exports.Default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _orchestrator = _interopRequireDefault(require("../utils/orchestrator"));
|
|
9
|
+
var _source = _interopRequireDefault(require("./source"));
|
|
10
|
+
var _defaultArgTypes = _interopRequireDefault(require("../utils/default-arg-types"));
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
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
|
+
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
|
+
var stories = {
|
|
20
|
+
title: 'Behaviour/Resizing',
|
|
21
|
+
component: _orchestrator["default"],
|
|
22
|
+
argTypes: _objectSpread(_objectSpread({}, _defaultArgTypes["default"]), {}, {
|
|
23
|
+
missing: {
|
|
24
|
+
table: {
|
|
25
|
+
disable: false
|
|
26
|
+
},
|
|
27
|
+
control: 'boolean',
|
|
28
|
+
defaultValue: true
|
|
29
|
+
},
|
|
30
|
+
activeGoNextForMissing: {
|
|
31
|
+
table: {
|
|
32
|
+
disable: false
|
|
33
|
+
},
|
|
34
|
+
control: 'boolean',
|
|
35
|
+
defaultValue: true
|
|
36
|
+
},
|
|
37
|
+
management: {
|
|
38
|
+
table: {
|
|
39
|
+
disable: false
|
|
40
|
+
},
|
|
41
|
+
control: 'boolean',
|
|
42
|
+
defaultValue: false
|
|
43
|
+
},
|
|
44
|
+
activeControls: {
|
|
45
|
+
control: 'boolean',
|
|
46
|
+
defaultValue: true
|
|
47
|
+
},
|
|
48
|
+
source: {
|
|
49
|
+
table: {
|
|
50
|
+
disable: false
|
|
51
|
+
},
|
|
52
|
+
control: {
|
|
53
|
+
type: 'object'
|
|
54
|
+
},
|
|
55
|
+
defaultValue: _source["default"]
|
|
56
|
+
},
|
|
57
|
+
data: {
|
|
58
|
+
table: {
|
|
59
|
+
disable: false
|
|
60
|
+
},
|
|
61
|
+
control: {
|
|
62
|
+
type: 'object'
|
|
63
|
+
},
|
|
64
|
+
defaultValue: {
|
|
65
|
+
COLLECTED: {
|
|
66
|
+
READY: {
|
|
67
|
+
COLLECTED: true
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
})
|
|
73
|
+
};
|
|
74
|
+
var _default = stories;
|
|
75
|
+
exports["default"] = _default;
|
|
76
|
+
var Template = function Template(args) {
|
|
77
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_orchestrator["default"], _objectSpread({}, args));
|
|
78
|
+
};
|
|
79
|
+
var Default = Template.bind({});
|
|
80
|
+
exports.Default = Default;
|
|
81
|
+
Default.args = {
|
|
82
|
+
id: 'resizing-default',
|
|
83
|
+
pagination: true
|
|
84
|
+
};
|
|
@@ -96,6 +96,22 @@
|
|
|
96
96
|
"type": "VTL"
|
|
97
97
|
}
|
|
98
98
|
},
|
|
99
|
+
"controls": [
|
|
100
|
+
{
|
|
101
|
+
"id": "roundabout-Carefull",
|
|
102
|
+
"criticality": "WARN",
|
|
103
|
+
"control": {
|
|
104
|
+
"value": "not(isnull(KNOWREC)) and not(isnull(SEXE)) and not(isnull(SOMETHING))",
|
|
105
|
+
"type": "VTL"
|
|
106
|
+
},
|
|
107
|
+
"type": "roundabout",
|
|
108
|
+
"iterations": { "value": "NB_HAB", "type": "VTL" },
|
|
109
|
+
"errorMessage": {
|
|
110
|
+
"value": "\"Le formulaire n'est pas complet pour \" || PRENOMS",
|
|
111
|
+
"type": "VTL|MD"
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
],
|
|
99
115
|
"components": [
|
|
100
116
|
{
|
|
101
117
|
"id": "radio",
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.SuggesterNotification = SuggesterNotification;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
|
+
var STATUS = {
|
|
11
|
+
unused: 0,
|
|
12
|
+
idle: 1,
|
|
13
|
+
pending: 2,
|
|
14
|
+
success: 3,
|
|
15
|
+
unknown: 4,
|
|
16
|
+
error: 5
|
|
17
|
+
};
|
|
18
|
+
function SuggesterNotification(props) {
|
|
19
|
+
var children = props.children,
|
|
20
|
+
status = props.status;
|
|
21
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
22
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
23
|
+
children: "status : ".concat(status)
|
|
24
|
+
}), children]
|
|
25
|
+
});
|
|
26
|
+
}
|
|
@@ -24,7 +24,7 @@ function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len
|
|
|
24
24
|
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; } }
|
|
25
25
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
26
26
|
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { Promise.resolve(value).then(_next, _throw); } }
|
|
27
|
-
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; }
|
|
27
|
+
function _asyncToGenerator(fn) { return function () { var self = this, args = arguments; return new Promise(function (resolve, reject) { var gen = fn.apply(self, args); function _next(value) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value); } function _throw(err) { asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err); } _next(undefined); }); }; } // import source from './source';
|
|
28
28
|
var stories = {
|
|
29
29
|
title: 'Components/Suggester-workers',
|
|
30
30
|
component: _orchestrator["default"],
|
|
@@ -76,7 +76,8 @@ var infoNaf = {
|
|
|
76
76
|
pattern: '[\\w.]+'
|
|
77
77
|
}
|
|
78
78
|
},
|
|
79
|
-
version: '1'
|
|
79
|
+
version: '1',
|
|
80
|
+
meloto: false
|
|
80
81
|
};
|
|
81
82
|
function loadOne(_x, _x2) {
|
|
82
83
|
return _loadOne.apply(this, arguments);
|
|
@@ -124,7 +125,8 @@ function Search(_ref) {
|
|
|
124
125
|
_ref$defaultValue = _ref.defaultValue,
|
|
125
126
|
defaultValue = _ref$defaultValue === void 0 ? '' : _ref$defaultValue;
|
|
126
127
|
var name = storeInfo.name,
|
|
127
|
-
order = storeInfo.order
|
|
128
|
+
order = storeInfo.order,
|
|
129
|
+
meloto = storeInfo.meloto;
|
|
128
130
|
var _useState = (0, _react.useState)(defaultValue),
|
|
129
131
|
_useState2 = _slicedToArray(_useState, 2),
|
|
130
132
|
value = _useState2[0],
|
|
@@ -144,7 +146,8 @@ function Search(_ref) {
|
|
|
144
146
|
name: name,
|
|
145
147
|
version: version,
|
|
146
148
|
max: max,
|
|
147
|
-
order: order
|
|
149
|
+
order: order,
|
|
150
|
+
meloto: meloto
|
|
148
151
|
});
|
|
149
152
|
case 2:
|
|
150
153
|
results = _context.sent;
|
|
@@ -160,7 +163,7 @@ function Search(_ref) {
|
|
|
160
163
|
if (value.length) {
|
|
161
164
|
doIt();
|
|
162
165
|
}
|
|
163
|
-
}, [value, name, version, max, order]);
|
|
166
|
+
}, [value, name, version, max, order, meloto]);
|
|
164
167
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
165
168
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
166
169
|
type: "search",
|
|
@@ -9,6 +9,7 @@ var _orchestrator = _interopRequireDefault(require("../utils/orchestrator"));
|
|
|
9
9
|
var _source = _interopRequireDefault(require("./source"));
|
|
10
10
|
var _simple = _interopRequireDefault(require("./simple"));
|
|
11
11
|
var _defaultArgTypes = _interopRequireDefault(require("../utils/default-arg-types"));
|
|
12
|
+
var _SuggesterNotification = require("./SuggesterNotification");
|
|
12
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
13
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
14
15
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, defineProperty = Object.defineProperty || function (obj, key, desc) { obj[key] = desc.value; }, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return defineProperty(generator, "_invoke", { value: makeInvokeMethod(innerFn, self, context) }), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; defineProperty(this, "_invoke", { value: function value(method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; } function maybeInvokeDelegate(delegate, context) { var methodName = context.method, method = delegate.iterator[methodName]; if (undefined === method) return context.delegate = null, "throw" === methodName && delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method) || "return" !== methodName && (context.method = "throw", context.arg = new TypeError("The iterator does not provide a '" + methodName + "' method")), ContinueSentinel; var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, defineProperty(Gp, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), defineProperty(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (val) { var object = Object(val), keys = []; for (var key in object) keys.push(key); return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
@@ -4,9 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.updateState = exports.onSetWaiting = exports.onInit = exports.handleChange = exports.goToPage = exports.goPreviousPage = exports.goNextPage = exports.ActionKind = void 0;
|
|
7
|
-
var ActionKind
|
|
8
|
-
exports.ActionKind = ActionKind;
|
|
9
|
-
(function (ActionKind) {
|
|
7
|
+
var ActionKind = /*#__PURE__*/function (ActionKind) {
|
|
10
8
|
ActionKind["GO_PREVIOUS_PAGE"] = "use-lunatic/go-previous";
|
|
11
9
|
ActionKind["GO_NEXT_PAGE"] = "use-lunatic/go-next";
|
|
12
10
|
ActionKind["GO_TO_PAGE"] = "use-lunatic/go-to-page";
|
|
@@ -14,7 +12,9 @@ exports.ActionKind = ActionKind;
|
|
|
14
12
|
ActionKind["HANDLE_CHANGE"] = "use-lunatic/handle-change";
|
|
15
13
|
ActionKind["ON_SET_WAITING"] = "use-lunatic/on-set-waiting";
|
|
16
14
|
ActionKind["UPDATE_STATE"] = "use-lunatic/update-state";
|
|
17
|
-
|
|
15
|
+
return ActionKind;
|
|
16
|
+
}({});
|
|
17
|
+
exports.ActionKind = ActionKind;
|
|
18
18
|
var actionCreator = function actionCreator(type) {
|
|
19
19
|
return function (payload) {
|
|
20
20
|
return {
|
|
@@ -40,7 +40,7 @@ var interpretAllCalculatedVariables = function interpretAllCalculatedVariables(_
|
|
|
40
40
|
bindingDependencies: bindingDependencies,
|
|
41
41
|
variables: variables
|
|
42
42
|
});
|
|
43
|
-
var shapeTarget = acc[shapeFrom];
|
|
43
|
+
var shapeTarget = shapeFrom ? acc[shapeFrom] : null;
|
|
44
44
|
if (shapeFrom && Array.isArray(shapeTarget)) {
|
|
45
45
|
var result = shapeTarget.map(function (_, index) {
|
|
46
46
|
var scopedBindings = buildScopedBindings({
|
|
@@ -5,7 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
7
|
var _commons = require("../reducer/commons");
|
|
8
|
-
var
|
|
8
|
+
var _resolveComponentControls = require("../reducer/resolve-component-controls");
|
|
9
|
+
var _replaceComponentSequence = require("../replace-component-sequence");
|
|
9
10
|
var _typeSource = require("../type-source");
|
|
10
11
|
var _fillComponentExpressions = _interopRequireDefault(require("./fill-components/fill-component-expressions"));
|
|
11
12
|
var _getComponentsFromState = _interopRequireDefault(require("./get-components-from-state"));
|
|
@@ -26,7 +27,7 @@ function validateComponents(state, components) {
|
|
|
26
27
|
var controls = component.controls,
|
|
27
28
|
id = component.id;
|
|
28
29
|
if (Array.isArray(controls)) {
|
|
29
|
-
var componentErrors = (0,
|
|
30
|
+
var componentErrors = (0, _resolveComponentControls.resolveComponentControls)(state, controls);
|
|
30
31
|
var shallowIteration = pager.shallowIteration;
|
|
31
32
|
var idC = shallowIteration !== undefined ? "".concat(id, "-").concat(shallowIteration) : id;
|
|
32
33
|
return (0, _getErrorsWithoutEmptyValue["default"])(_objectSpread(_objectSpread({}, errors), {}, _defineProperty({}, idC, componentErrors)));
|
|
@@ -53,7 +54,7 @@ function isCriticalErrors(errors) {
|
|
|
53
54
|
return false;
|
|
54
55
|
}
|
|
55
56
|
function computeErrors(state) {
|
|
56
|
-
var components = (0, _getComponentsFromState["default"])(state);
|
|
57
|
+
var components = (0, _replaceComponentSequence.replaceComponentSequence)((0, _getComponentsFromState["default"])(state));
|
|
57
58
|
var componentFiltered = components.map(function (component) {
|
|
58
59
|
return (0, _fillComponentExpressions["default"])(component, state);
|
|
59
60
|
}).filter(function (_ref2) {
|
|
@@ -0,0 +1,155 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _createExecuteExpression = _interopRequireDefault(require("./create-execute-expression"));
|
|
4
|
+
var _vitest = require("vitest");
|
|
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
|
+
var variables = {
|
|
13
|
+
LASTNAME: {
|
|
14
|
+
CalculatedLinked: [],
|
|
15
|
+
type: 'COLLECTED',
|
|
16
|
+
value: 'Doe',
|
|
17
|
+
variable: {
|
|
18
|
+
name: 'LASTNAME',
|
|
19
|
+
variableType: 'COLLECTED'
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
GREETING: {
|
|
23
|
+
CalculatedLinked: [],
|
|
24
|
+
value: 'Hello Doe',
|
|
25
|
+
type: 'CALCULATED',
|
|
26
|
+
variable: {
|
|
27
|
+
name: 'GREETING',
|
|
28
|
+
variableType: 'COLLECTED',
|
|
29
|
+
expression: {
|
|
30
|
+
value: '"Hello " || LASTNAME',
|
|
31
|
+
type: 'VTL'
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
},
|
|
35
|
+
PAIRWISE: {
|
|
36
|
+
CalculatedLinked: [],
|
|
37
|
+
type: 'COLLECTED',
|
|
38
|
+
value: [['a1', 'a2'], ['b1', 'b2']],
|
|
39
|
+
variable: {
|
|
40
|
+
name: 'PAIRWISE',
|
|
41
|
+
variableType: 'COLLECTED'
|
|
42
|
+
}
|
|
43
|
+
},
|
|
44
|
+
PRENOMS: {
|
|
45
|
+
CalculatedLinked: [],
|
|
46
|
+
type: 'COLLECTED',
|
|
47
|
+
value: [],
|
|
48
|
+
variable: {
|
|
49
|
+
name: 'PRENOMS',
|
|
50
|
+
variableType: 'COLLECTED'
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
PRENOMVIDE: {
|
|
54
|
+
CalculatedLinked: [],
|
|
55
|
+
type: 'CALCULATED',
|
|
56
|
+
variable: {
|
|
57
|
+
name: 'PRENOMVIDE',
|
|
58
|
+
variableType: 'CALCULATED',
|
|
59
|
+
expression: {
|
|
60
|
+
value: '"empty"',
|
|
61
|
+
type: 'VTL'
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
PRENOMS_WITH_DEFAULTS: {
|
|
66
|
+
CalculatedLinked: [],
|
|
67
|
+
variable: {
|
|
68
|
+
variableType: 'CALCULATED',
|
|
69
|
+
name: 'PRENOMS_WITH_DEFAULTS',
|
|
70
|
+
expression: {
|
|
71
|
+
value: 'if (isnull(PRENOMS)) then PRENOMVIDE else PRENOMS',
|
|
72
|
+
type: 'VTL'
|
|
73
|
+
},
|
|
74
|
+
bindingDependencies: ['PRENOMS', 'PRENOMVIDE'],
|
|
75
|
+
shapeFrom: 'PRENOMS'
|
|
76
|
+
},
|
|
77
|
+
type: 'CALCULATED'
|
|
78
|
+
},
|
|
79
|
+
PRENOMS_SIZE: {
|
|
80
|
+
CalculatedLinked: [],
|
|
81
|
+
variable: {
|
|
82
|
+
variableType: 'CALCULATED',
|
|
83
|
+
name: 'PRENOMS_SIZE',
|
|
84
|
+
expression: {
|
|
85
|
+
value: 'count(PRENOMS)',
|
|
86
|
+
type: 'VTL'
|
|
87
|
+
},
|
|
88
|
+
bindingDependencies: ['PRENOMS']
|
|
89
|
+
},
|
|
90
|
+
type: 'CALCULATED'
|
|
91
|
+
}
|
|
92
|
+
};
|
|
93
|
+
variables.PRENOMS.CalculatedLinked = [variables.PRENOMS_WITH_DEFAULTS.variable, variables.PRENOMS_SIZE.variable];
|
|
94
|
+
variables.LASTNAME.CalculatedLinked = [variables.GREETING.variable];
|
|
95
|
+
(0, _vitest.describe)('createExecuteExpression', function () {
|
|
96
|
+
var execute, update;
|
|
97
|
+
(0, _vitest.beforeEach)(function () {
|
|
98
|
+
var _createExecuteExpress = (0, _createExecuteExpression["default"])(variables, ['VTL', 'VTL|MD']);
|
|
99
|
+
var _createExecuteExpress2 = _slicedToArray(_createExecuteExpress, 2);
|
|
100
|
+
execute = _createExecuteExpress2[0];
|
|
101
|
+
update = _createExecuteExpress2[1];
|
|
102
|
+
});
|
|
103
|
+
(0, _vitest.it)('should retrieve collected value', function () {
|
|
104
|
+
(0, _vitest.expect)(execute('LASTNAME')).toBe('Doe');
|
|
105
|
+
(0, _vitest.expect)(execute('"John " || LASTNAME')).toBe('John Doe');
|
|
106
|
+
});
|
|
107
|
+
_vitest.it.skip('should hangle calculated value', function () {
|
|
108
|
+
(0, _vitest.expect)(execute('GREETING')).toBe('Hello Doe');
|
|
109
|
+
update('LASTNAME', 'Doee');
|
|
110
|
+
(0, _vitest.expect)(execute('GREETING')).toBe('Hello Doee');
|
|
111
|
+
});
|
|
112
|
+
(0, _vitest.it)('should handle updated value', function () {
|
|
113
|
+
(0, _vitest.expect)(execute('LASTNAME')).toBe('Doe');
|
|
114
|
+
update('LASTNAME', 'John');
|
|
115
|
+
(0, _vitest.expect)(execute('LASTNAME')).toBe('John');
|
|
116
|
+
});
|
|
117
|
+
(0, _vitest.it)('should handle 1D vectors', function () {
|
|
118
|
+
update('PRENOMS', ['Jane', 'John', 'James']);
|
|
119
|
+
(0, _vitest.expect)(execute('PRENOMS', {
|
|
120
|
+
iteration: 1
|
|
121
|
+
})).toBe('John');
|
|
122
|
+
(0, _vitest.expect)(execute('PRENOMS', {
|
|
123
|
+
iteration: 0
|
|
124
|
+
})).toBe('Jane');
|
|
125
|
+
(0, _vitest.expect)(execute('PRENOMS_SIZE', {
|
|
126
|
+
iteration: 1
|
|
127
|
+
})).toBe(3);
|
|
128
|
+
(0, _vitest.expect)(execute('PRENOMS_WITH_DEFAULTS', {
|
|
129
|
+
iteration: 1
|
|
130
|
+
})).toBe('John');
|
|
131
|
+
update('PRENOMS', [null, null]);
|
|
132
|
+
(0, _vitest.expect)(execute('PRENOMS', {
|
|
133
|
+
iteration: 1
|
|
134
|
+
})).toBe(null);
|
|
135
|
+
(0, _vitest.expect)(execute('PRENOMS_WITH_DEFAULTS', {
|
|
136
|
+
iteration: 1
|
|
137
|
+
})).toBe('empty');
|
|
138
|
+
(0, _vitest.expect)(execute('PRENOMS_SIZE')).toBe(2);
|
|
139
|
+
});
|
|
140
|
+
(0, _vitest.it)('should handle 2D Vectors', function () {
|
|
141
|
+
(0, _vitest.expect)(execute('PAIRWISE', {
|
|
142
|
+
linksIterations: [0, 1]
|
|
143
|
+
})).toBe('a2');
|
|
144
|
+
(0, _vitest.expect)(execute('PAIRWISE', {
|
|
145
|
+
linksIterations: [1, 1]
|
|
146
|
+
})).toBe('b2');
|
|
147
|
+
});
|
|
148
|
+
(0, _vitest.it)('should handle direct expression', function () {
|
|
149
|
+
update('PRENOMS', ['Jane', 'John', 'James']);
|
|
150
|
+
(0, _vitest.expect)(execute('count(PRENOMS)')).toBe(3);
|
|
151
|
+
(0, _vitest.expect)(execute('PRENOMS || " Doe"', {
|
|
152
|
+
iteration: 0
|
|
153
|
+
})).toBe('Jane Doe');
|
|
154
|
+
});
|
|
155
|
+
});
|
|
@@ -103,8 +103,9 @@ function createRefreshCalculated(_ref) {
|
|
|
103
103
|
bindings[name] = value;
|
|
104
104
|
return value;
|
|
105
105
|
}
|
|
106
|
-
function refreshCalculated(map
|
|
107
|
-
var
|
|
106
|
+
function refreshCalculated(map) {
|
|
107
|
+
var _ref4 = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
|
108
|
+
rootExpression = _ref4.rootExpression,
|
|
108
109
|
iteration = _ref4.iteration,
|
|
109
110
|
linksIterations = _ref4.linksIterations;
|
|
110
111
|
return Object.entries(map).reduce(function (sub, _ref5) {
|
|
@@ -0,0 +1,128 @@
|
|
|
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
|
+
return _construct(Function, _toConsumableArray(Object.keys(bindings)).concat(["return ".concat(expression.value)])).apply(void 0, _toConsumableArray(Object.values(bindings).map(function (value) {
|
|
73
|
+
return options.iteration !== undefined && Array.isArray(value) ? value[options.iteration] : value;
|
|
74
|
+
})));
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
(0, _vitest.describe)('createRefreshCalculated', function () {
|
|
78
|
+
(0, _vitest.it)('should recalculate simple variable', function () {
|
|
79
|
+
var bindings = {
|
|
80
|
+
AGE: [10, 20, 30]
|
|
81
|
+
};
|
|
82
|
+
var _createRefreshCalcula = (0, _createRefreshCalculated["default"])({
|
|
83
|
+
variables: variables,
|
|
84
|
+
execute: fakeExecute(bindings),
|
|
85
|
+
bindings: bindings
|
|
86
|
+
}),
|
|
87
|
+
_createRefreshCalcula2 = _slicedToArray(_createRefreshCalcula, 1),
|
|
88
|
+
refresh = _createRefreshCalcula2[0];
|
|
89
|
+
(0, _vitest.expect)(refresh(variables, {}).COUNT_AGES).toBe(3);
|
|
90
|
+
(0, _vitest.expect)(refresh(variables, {
|
|
91
|
+
iteration: 1
|
|
92
|
+
}).COUNT_AGES).toBe(3);
|
|
93
|
+
(0, _vitest.expect)(bindings.AGE).toEqual([10, 20, 30]);
|
|
94
|
+
(0, _vitest.expect)(bindings.COUNT_AGES).toEqual(3);
|
|
95
|
+
});
|
|
96
|
+
(0, _vitest.it)('should recalculate loop variables', function () {
|
|
97
|
+
var bindings = {
|
|
98
|
+
AGE: [10, 20, 30]
|
|
99
|
+
};
|
|
100
|
+
var _createRefreshCalcula3 = (0, _createRefreshCalculated["default"])({
|
|
101
|
+
variables: variables,
|
|
102
|
+
execute: fakeExecute(bindings),
|
|
103
|
+
bindings: bindings
|
|
104
|
+
}),
|
|
105
|
+
_createRefreshCalcula4 = _slicedToArray(_createRefreshCalcula3, 1),
|
|
106
|
+
refresh = _createRefreshCalcula4[0];
|
|
107
|
+
(0, _vitest.expect)(refresh(variables).AGE_ONE_PLUS).toEqual([11, 21, 31]);
|
|
108
|
+
(0, _vitest.expect)(bindings.AGE).toEqual([10, 20, 30]);
|
|
109
|
+
(0, _vitest.expect)(bindings.AGE_ONE_PLUS).toEqual([11, 21, 31]);
|
|
110
|
+
});
|
|
111
|
+
(0, _vitest.it)('should recalculate loop variables with specific iteration', function () {
|
|
112
|
+
var bindings = {
|
|
113
|
+
AGE: [10, 20, 30]
|
|
114
|
+
};
|
|
115
|
+
var _createRefreshCalcula5 = (0, _createRefreshCalculated["default"])({
|
|
116
|
+
variables: variables,
|
|
117
|
+
execute: fakeExecute(bindings),
|
|
118
|
+
bindings: bindings
|
|
119
|
+
}),
|
|
120
|
+
_createRefreshCalcula6 = _slicedToArray(_createRefreshCalcula5, 1),
|
|
121
|
+
refresh = _createRefreshCalcula6[0];
|
|
122
|
+
(0, _vitest.expect)(refresh(variables, {
|
|
123
|
+
iteration: 1
|
|
124
|
+
}).AGE_ONE_PLUS).toEqual(21);
|
|
125
|
+
(0, _vitest.expect)(bindings.AGE).toEqual([10, 20, 30]);
|
|
126
|
+
(0, _vitest.expect)(bindings.AGE_ONE_PLUS).toEqual([11, 21, 31]);
|
|
127
|
+
});
|
|
128
|
+
});
|
|
@@ -24,7 +24,10 @@ var VTL_ATTRIBUTES = ['label', 'options.label', 'responses.label', 'hierarchy.la
|
|
|
24
24
|
// Disable controls compilation
|
|
25
25
|
// 'controls.control',
|
|
26
26
|
// 'controls.errorMessage',
|
|
27
|
-
'lines.min', 'lines.max', 'iterations', 'xAxisIterations', 'yAxisIterations', 'conditionFilter', 'headers.label', 'header.label'];
|
|
27
|
+
'controls.iterations', 'lines.min', 'lines.max', 'iterations', 'xAxisIterations', 'yAxisIterations', 'conditionFilter', 'headers.label', 'header.label'];
|
|
28
|
+
|
|
29
|
+
// Utility type to replace all expression from an object into a translated version
|
|
30
|
+
|
|
28
31
|
function createCrawl(_ref) {
|
|
29
32
|
var executeExpression = _ref.executeExpression,
|
|
30
33
|
iteration = _ref.iteration,
|
|
@@ -181,8 +181,7 @@ function reduceOnInit(state, action) {
|
|
|
181
181
|
management = payload.management,
|
|
182
182
|
shortcut = payload.shortcut,
|
|
183
183
|
activeControls = payload.activeControls,
|
|
184
|
-
goToPage = payload.goToPage
|
|
185
|
-
withOverview = payload.withOverview;
|
|
184
|
+
goToPage = payload.goToPage;
|
|
186
185
|
if (source && data) {
|
|
187
186
|
var _initialPager$page;
|
|
188
187
|
var variables = createVariables(source, data); // map des variables
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
Object.defineProperty(exports, "resolveComponentControls", {
|
|
7
|
+
enumerable: true,
|
|
8
|
+
get: function get() {
|
|
9
|
+
return _resolveComponentControl.resolveComponentControls;
|
|
10
|
+
}
|
|
11
|
+
});
|
|
12
|
+
var _resolveComponentControl = require("./resolve-component-control");
|