@inseefr/lunatic 2.7.1 → 2.7.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 +45 -11
- package/lib/components/checkbox/checkbox-boolean/html/checkbox-boolean.js +3 -3
- package/lib/components/checkbox/checkbox-boolean/lunatic-checkbox-boolean.js +2 -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 -2
- 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/DatepickerField.js +47 -0
- package/lib/components/datepicker/html/__snapshots__/datepicker.spec.tsx.snap +209 -17
- package/lib/components/datepicker/html/datepicker.js +104 -21
- package/lib/components/datepicker/html/datepicker.scss +19 -1
- package/lib/components/datepicker/html/datepicker.spec.js +71 -23
- package/lib/components/datepicker/lunatic-datepicker.js +5 -2
- package/lib/components/dropdown/lunatic-dropdown.js +2 -1
- package/lib/components/duration/duration.js +6 -7
- package/lib/components/duration/duration.scss +6 -14
- package/lib/components/duration/durationInput.js +14 -8
- package/lib/components/duration/durationUtils.js +38 -8
- 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 +3 -3
- package/lib/components/loop/roster-for-loop/__snapshots__/roster-for-loop.spec.tsx.snap +88 -0
- package/lib/components/loop/roster-for-loop/roster-for-loop.js +7 -3
- package/lib/components/loop/roster-for-loop/roster-for-loop.spec.js +46 -0
- package/lib/components/lunatic-components.js +2 -11
- 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 +5 -5
- package/lib/components/suggester/idb-suggester/check-store.js +6 -3
- package/lib/components/suggester/idb-suggester/idb-suggester.js +8 -7
- package/lib/components/suggester/idb-suggester/suggester-status.js +1 -4
- package/lib/components/suggester/lunatic-suggester.js +7 -4
- package/lib/components/suggester/searching/create-searching.js +19 -42
- package/lib/components/suggester-loader-widget/loader-row.js +4 -2
- package/lib/components/suggester-loader-widget/loader.js +5 -4
- package/lib/components/suggester-loader-widget/widget.js +8 -8
- package/lib/components/switch/html/switch.js +2 -2
- package/lib/components/switch/lunatic-switch.js +2 -1
- package/lib/components/table/lunatic-table.js +2 -2
- 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/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/DatepickerField.d.ts +12 -0
- package/lib/src/components/datepicker/html/datepicker.d.ts +4 -3
- package/lib/src/components/datepicker/lunatic-datepicker.d.ts +1 -0
- 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/duration/durationInput.d.ts +6 -2
- package/lib/src/components/duration/durationUtils.d.ts +24 -7
- 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/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/check-store.d.ts +5 -2
- package/lib/src/components/suggester/idb-suggester/idb-suggester.d.ts +5 -2
- package/lib/src/components/suggester/idb-suggester/suggester-status.d.ts +1 -4
- 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/suggester-loader-widget/loader-row.d.ts +2 -1
- package/lib/src/components/suggester-loader-widget/loader.d.ts +2 -1
- package/lib/src/components/suggester-loader-widget/widget.d.ts +3 -2
- package/lib/src/components/switch/html/switch.d.ts +1 -1
- package/lib/src/components/textarea/html/textarea.d.ts +3 -2
- package/lib/src/components/type.d.ts +5 -3
- package/lib/src/hooks/use-auto-focus.d.ts +6 -0
- package/lib/src/use-lunatic/actions.d.ts +2 -0
- package/lib/src/use-lunatic/commons/fill-components/fill-component-required.d.ts +383 -0
- package/lib/src/use-lunatic/commons/fill-components/fill-component-value.d.ts +1 -1
- package/lib/src/use-lunatic/commons/fill-components/fill-component-value.spec.d.ts +1 -0
- package/lib/src/use-lunatic/commons/fill-components/fill-from-state.d.ts +20 -0
- package/lib/src/use-lunatic/commons/variables/lunatic-variables-store.d.ts +4 -0
- package/lib/src/use-lunatic/reducer/overview/overview-on-init.d.ts +1 -0
- package/lib/src/use-lunatic/type.d.ts +1 -0
- package/lib/src/use-lunatic/use-lunatic.d.ts +8 -3
- package/lib/src/use-lunatic/use-suggesters.d.ts +2 -1
- package/lib/src/utils/suggester-workers/append-to-index/create-append-task.d.ts +2 -2
- package/lib/src/utils/suggester-workers/worker-path.d.ts +6 -0
- package/lib/stories/behaviour/cleaning/source.json +151 -0
- package/lib/stories/behaviour/cleaning/test.stories.js +83 -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 +5 -4
- package/lib/stories/{resizing-questionnaire → behaviour/resizing}/test.stories.js +5 -4
- package/lib/stories/date-picker/datepicker.stories.js +32 -29
- package/lib/stories/duration/duration.stories.js +4 -4
- package/lib/stories/duration/{source.json → mois.json} +1 -1
- package/lib/stories/duration/{source1.json → time.json} +1 -1
- package/lib/stories/loop/not-paginated-loop.stories.js +35 -0
- package/lib/stories/loop/source-bloc.json +2 -2
- package/lib/stories/loop/source-not-paginated.json +138 -0
- package/lib/stories/loop/source-paginated.json +2 -2
- package/lib/stories/suggester/suggester.stories.js +6 -37
- package/lib/stories/utils/referentiel.js +38 -0
- package/lib/use-lunatic/commons/fill-components/fill-component-required.js +23 -0
- package/lib/use-lunatic/commons/fill-components/fill-component-value.js +1 -1
- package/lib/use-lunatic/commons/fill-components/fill-component-value.spec.js +67 -0
- package/lib/use-lunatic/commons/fill-components/fill-components.js +2 -1
- package/lib/use-lunatic/commons/fill-components/fill-from-state.js +2 -0
- package/lib/use-lunatic/commons/variables/lunatic-variables-store.js +15 -0
- package/lib/use-lunatic/commons/variables/lunatic-variables-store.spec.js +9 -1
- package/lib/use-lunatic/initial-state.js +2 -1
- package/lib/use-lunatic/reducer/reduce-on-init.js +4 -2
- package/lib/use-lunatic/use-lunatic.js +7 -3
- package/lib/use-lunatic/use-suggesters.js +55 -38
- package/lib/utils/env.js +9 -1
- package/lib/utils/suggester-workers/append-to-index/create-append-task.js +5 -4
- package/lib/utils/suggester-workers/create-worker.js +7 -1
- package/lib/utils/suggester-workers/worker-path.js +29 -0
- package/package.json +24 -11
- package/scripts/build/add-workers-to-public.js +44 -0
- package/scripts/build/workers-paths.js +45 -0
- package/workers-release/lunatic-append-worker-0.3.0.js +2 -0
- package/workers-release/lunatic-append-worker-0.3.0.js.LICENSE.txt +34 -0
- package/workers-release/lunatic-label-worker-0.3.0.js +2 -0
- package/workers-release/lunatic-label-worker-0.3.0.js.LICENSE.txt +13 -0
- package/workers-release/lunatic-search-worker-0.3.0.js +2 -0
- package/workers-release/lunatic-search-worker-0.3.0.js.LICENSE.txt +34 -0
- package/lib/components/datepicker/html/datepicker-container.js +0 -17
- package/lib/components/datepicker/html/datepicker-input.js +0 -35
- package/lib/env.d.js +0 -1
- package/lib/src/components/datepicker/html/datepicker-container.d.ts +0 -3
- package/lib/src/components/datepicker/html/datepicker-input.d.ts +0 -13
- package/lib/src/utils/get-component-value.d.ts +0 -5
- package/lib/src/utils/store-tools/worker-path.d.ts +0 -1
- package/lib/utils/get-component-value.js +0 -34
- package/lib/utils/get-component-value.test.js +0 -57
- package/lib/utils/store-tools/worker-path.js +0 -13
- package/lib/utils/suggester-workers/create-worker-ts.js +0 -54
- /package/lib/src/{utils/get-component-value.test.d.ts → components/loop/roster-for-loop/roster-for-loop.spec.d.ts} +0 -0
- /package/lib/src/utils/suggester-workers/{create-worker-ts.d.ts → create-worker.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
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"page": "2.1",
|
|
41
41
|
"maxLength": 20,
|
|
42
42
|
"label": {
|
|
43
|
-
"value": "\"Questions 1, Itération : \" || GLOBAL_ITERATION_INDEX",
|
|
43
|
+
"value": "\"Questions 1, Itération : \" || cast(GLOBAL_ITERATION_INDEX, string)",
|
|
44
44
|
"type": "VTL"
|
|
45
45
|
},
|
|
46
46
|
"conditionFilter": {
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"page": "2.2",
|
|
57
57
|
"maxLength": 20,
|
|
58
58
|
"label": {
|
|
59
|
-
"value": "\"Vous avez mis en question 1, itération \" || GLOBAL_ITERATION_INDEX || \" : \" || LIBELLE",
|
|
59
|
+
"value": "\"Vous avez mis en question 1, itération \" || cast(GLOBAL_ITERATION_INDEX, string) || \" : \" || LIBELLE",
|
|
60
60
|
"type": "VTL"
|
|
61
61
|
},
|
|
62
62
|
"conditionFilter": {
|
|
@@ -5,17 +5,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = exports.Simple = exports.Default = exports.ComponentSet = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _defaultArgTypes = _interopRequireDefault(require("../utils/default-arg-types"));
|
|
8
9
|
var _orchestrator = _interopRequireDefault(require("../utils/orchestrator"));
|
|
9
|
-
var
|
|
10
|
+
var _referentiel = require("../utils/referentiel");
|
|
10
11
|
var _simple = _interopRequireDefault(require("./simple"));
|
|
12
|
+
var _source = _interopRequireDefault(require("./source"));
|
|
11
13
|
var _sourceComponentSet = _interopRequireDefault(require("./source-component-set"));
|
|
12
|
-
var _defaultArgTypes = _interopRequireDefault(require("../utils/default-arg-types"));
|
|
13
14
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
15
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
16
16
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
17
|
-
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); } }
|
|
18
|
-
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); }); }; }
|
|
19
17
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
20
18
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
21
19
|
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; }
|
|
@@ -31,46 +29,17 @@ var Template = function Template(args) {
|
|
|
31
29
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_orchestrator["default"], _objectSpread({}, args));
|
|
32
30
|
};
|
|
33
31
|
var Default = exports.Default = Template.bind({});
|
|
34
|
-
function getReferentiel(_x) {
|
|
35
|
-
return _getReferentiel.apply(this, arguments);
|
|
36
|
-
}
|
|
37
|
-
function _getReferentiel() {
|
|
38
|
-
_getReferentiel = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(name) {
|
|
39
|
-
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
40
|
-
while (1) switch (_context.prev = _context.next) {
|
|
41
|
-
case 0:
|
|
42
|
-
_context.t0 = name;
|
|
43
|
-
_context.next = _context.t0 === 'naf-rev2-stop' ? 3 : _context.t0 === 'naf-rev2' ? 3 : _context.t0 === 'cog-communes' ? 4 : 5;
|
|
44
|
-
break;
|
|
45
|
-
case 3:
|
|
46
|
-
return _context.abrupt("return", fetch('https://inseefr.github.io/Lunatic/storybook/naf-rev2.json').then(function (r) {
|
|
47
|
-
return r.json();
|
|
48
|
-
}));
|
|
49
|
-
case 4:
|
|
50
|
-
return _context.abrupt("return", fetch('https://inseefr.github.io/Lunatic/storybook/communes-2019.json').then(function (r) {
|
|
51
|
-
return r.json();
|
|
52
|
-
}));
|
|
53
|
-
case 5:
|
|
54
|
-
throw new Error("Unkonw r\xE9f\xE9rentiel ".concat(name));
|
|
55
|
-
case 6:
|
|
56
|
-
case "end":
|
|
57
|
-
return _context.stop();
|
|
58
|
-
}
|
|
59
|
-
}, _callee);
|
|
60
|
-
}));
|
|
61
|
-
return _getReferentiel.apply(this, arguments);
|
|
62
|
-
}
|
|
63
32
|
Default.args = {
|
|
64
33
|
id: 'suggester',
|
|
65
34
|
source: _source["default"],
|
|
66
35
|
autoSuggesterLoading: true,
|
|
67
|
-
getReferentiel: getReferentiel,
|
|
36
|
+
getReferentiel: _referentiel.getReferentiel,
|
|
68
37
|
pagination: true
|
|
69
38
|
};
|
|
70
39
|
var Simple = exports.Simple = Template.bind({});
|
|
71
40
|
Simple.args = {
|
|
72
41
|
source: _simple["default"],
|
|
73
|
-
getReferentiel: getReferentiel,
|
|
42
|
+
getReferentiel: _referentiel.getReferentiel,
|
|
74
43
|
autoSuggesterLoading: true,
|
|
75
44
|
missing: {
|
|
76
45
|
table: {
|
|
@@ -83,6 +52,6 @@ Simple.args = {
|
|
|
83
52
|
var ComponentSet = exports.ComponentSet = Template.bind({});
|
|
84
53
|
ComponentSet.args = {
|
|
85
54
|
source: _sourceComponentSet["default"],
|
|
86
|
-
getReferentiel: getReferentiel,
|
|
55
|
+
getReferentiel: _referentiel.getReferentiel,
|
|
87
56
|
autoSuggesterLoading: true
|
|
88
57
|
};
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
+
Object.defineProperty(exports, "__esModule", {
|
|
5
|
+
value: true
|
|
6
|
+
});
|
|
7
|
+
exports.getReferentiel = void 0;
|
|
8
|
+
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 e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
9
|
+
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); } }
|
|
10
|
+
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); }); }; }
|
|
11
|
+
var getReferentiel = exports.getReferentiel = /*#__PURE__*/function () {
|
|
12
|
+
var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(name) {
|
|
13
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
14
|
+
while (1) switch (_context.prev = _context.next) {
|
|
15
|
+
case 0:
|
|
16
|
+
_context.t0 = name;
|
|
17
|
+
_context.next = _context.t0 === 'naf-rev2-stop' ? 3 : _context.t0 === 'naf-rev2' ? 3 : _context.t0 === 'cog-communes' ? 4 : 5;
|
|
18
|
+
break;
|
|
19
|
+
case 3:
|
|
20
|
+
return _context.abrupt("return", fetch('https://inseefr.github.io/Lunatic/storybook/naf-rev2.json').then(function (r) {
|
|
21
|
+
return r.json();
|
|
22
|
+
}));
|
|
23
|
+
case 4:
|
|
24
|
+
return _context.abrupt("return", fetch('https://inseefr.github.io/Lunatic/storybook/communes-2019.json').then(function (r) {
|
|
25
|
+
return r.json();
|
|
26
|
+
}));
|
|
27
|
+
case 5:
|
|
28
|
+
throw new Error("Unkonw r\xE9f\xE9rentiel ".concat(name));
|
|
29
|
+
case 6:
|
|
30
|
+
case "end":
|
|
31
|
+
return _context.stop();
|
|
32
|
+
}
|
|
33
|
+
}, _callee);
|
|
34
|
+
}));
|
|
35
|
+
return function getReferentiel(_x) {
|
|
36
|
+
return _ref.apply(this, arguments);
|
|
37
|
+
};
|
|
38
|
+
}();
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.fillComponentRequired = fillComponentRequired;
|
|
7
|
+
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
8
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
11
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
12
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
13
|
+
/**
|
|
14
|
+
* Add required attribute on component that are mandatory
|
|
15
|
+
*/
|
|
16
|
+
function fillComponentRequired(component) {
|
|
17
|
+
if (component.mandatory) {
|
|
18
|
+
return _objectSpread(_objectSpread({}, component), {}, {
|
|
19
|
+
required: true
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
return component;
|
|
23
|
+
}
|
|
@@ -24,7 +24,7 @@ function getValueForComponent(component, state) {
|
|
|
24
24
|
}
|
|
25
25
|
if ((0, _component.hasResponses)(component)) {
|
|
26
26
|
var _component$responses$, _component$responses;
|
|
27
|
-
return Object.
|
|
27
|
+
return Object.fromEntries((_component$responses$ = (_component$responses = component.responses) === null || _component$responses === void 0 ? void 0 : _component$responses.map(function (_ref) {
|
|
28
28
|
var response = _ref.response;
|
|
29
29
|
return [response.name, state.variables.get(response.name, iteration)];
|
|
30
30
|
})) !== null && _component$responses$ !== void 0 ? _component$responses$ : []);
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _vitest = require("vitest");
|
|
4
|
+
var _fillComponentValue = require("./fill-component-value");
|
|
5
|
+
var _lunaticVariablesStore = require("../variables/lunatic-variables-store");
|
|
6
|
+
var _array = require("../../../utils/array");
|
|
7
|
+
(0, _vitest.describe)('fillComponentValue', function () {
|
|
8
|
+
// Helper to avoid repetition
|
|
9
|
+
var expectFilledComponent = function expectFilledComponent(component) {
|
|
10
|
+
var values = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
11
|
+
var iteration = arguments.length > 2 ? arguments[2] : undefined;
|
|
12
|
+
return (0, _vitest.expect)((0, _fillComponentValue.fillComponentValue)(component, {
|
|
13
|
+
variables: _lunaticVariablesStore.LunaticVariablesStore.makeFromObject(values),
|
|
14
|
+
pager: {
|
|
15
|
+
maxPage: '2',
|
|
16
|
+
page: '1',
|
|
17
|
+
iteration: iteration
|
|
18
|
+
}
|
|
19
|
+
}).value);
|
|
20
|
+
};
|
|
21
|
+
(0, _vitest.describe)('response', function () {
|
|
22
|
+
var component = {
|
|
23
|
+
response: {
|
|
24
|
+
name: 'PRENOM'
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
(0, _vitest.it)('Should work with simple response', function () {
|
|
28
|
+
expectFilledComponent(component, {
|
|
29
|
+
PRENOM: 'John'
|
|
30
|
+
}).toBe('John');
|
|
31
|
+
expectFilledComponent(component).toBe(null);
|
|
32
|
+
});
|
|
33
|
+
(0, _vitest.it)('Should work with simple response as Array', function () {
|
|
34
|
+
expectFilledComponent(component, {
|
|
35
|
+
PRENOM: ['John', 'Renaud']
|
|
36
|
+
}, 1).toBe('Renaud');
|
|
37
|
+
expectFilledComponent(component, {
|
|
38
|
+
PRENOM: ['John', 'Renaud']
|
|
39
|
+
}, 3).toBe(undefined);
|
|
40
|
+
});
|
|
41
|
+
});
|
|
42
|
+
(0, _vitest.describe)('responses', function () {
|
|
43
|
+
var component = {
|
|
44
|
+
responses: (0, _array.times)(3, function (k) {
|
|
45
|
+
return {
|
|
46
|
+
response: {
|
|
47
|
+
name: "NAME".concat(k)
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
})
|
|
51
|
+
};
|
|
52
|
+
(0, _vitest.it)('should work with multiple responses', function () {
|
|
53
|
+
expectFilledComponent(component).toEqual({
|
|
54
|
+
NAME0: null,
|
|
55
|
+
NAME1: null,
|
|
56
|
+
NAME2: null
|
|
57
|
+
});
|
|
58
|
+
expectFilledComponent(component, {
|
|
59
|
+
NAME1: true
|
|
60
|
+
}).toEqual({
|
|
61
|
+
NAME0: null,
|
|
62
|
+
NAME1: true,
|
|
63
|
+
NAME2: null
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
});
|
|
67
|
+
});
|
|
@@ -11,6 +11,7 @@ var _fillManagement = _interopRequireDefault(require("./fill-management"));
|
|
|
11
11
|
var _fillMissingResponse = _interopRequireDefault(require("./fill-missing-response"));
|
|
12
12
|
var _fillPagination = _interopRequireDefault(require("./fill-pagination"));
|
|
13
13
|
var _fillSpecificExpression = _interopRequireDefault(require("./fill-specific-expression"));
|
|
14
|
+
var _fillComponentRequired = require("./fill-component-required");
|
|
14
15
|
var _fillIterations = require("./fill-iterations");
|
|
15
16
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
16
17
|
/**
|
|
@@ -36,7 +37,7 @@ function compose() {
|
|
|
36
37
|
*
|
|
37
38
|
* Force typing for this function since it's doo dynamic
|
|
38
39
|
*/
|
|
39
|
-
var fillComponent = exports.fillComponent = compose(_fillFromState["default"], _fillComponentExpressions["default"], _fillPagination["default"], _fillComponentValue.fillComponentValue, _fillMissingResponse["default"], _fillManagement["default"], _fillIterations.fillIterations, _fillSpecificExpression["default"]);
|
|
40
|
+
var fillComponent = exports.fillComponent = compose(_fillFromState["default"], _fillComponentExpressions["default"], _fillPagination["default"], _fillComponentValue.fillComponentValue, _fillMissingResponse["default"], _fillComponentRequired.fillComponentRequired, _fillManagement["default"], _fillIterations.fillIterations, _fillSpecificExpression["default"]);
|
|
40
41
|
|
|
41
42
|
/**
|
|
42
43
|
* Fill components with values coming from the state, and interpret VTL expression
|
|
@@ -20,6 +20,7 @@ function fillFromState(component, state) {
|
|
|
20
20
|
goToPage = state.goToPage,
|
|
21
21
|
shortcut = state.shortcut,
|
|
22
22
|
getSuggesterStatus = state.getSuggesterStatus,
|
|
23
|
+
workersBasePath = state.workersBasePath,
|
|
23
24
|
goNextPage = state.goNextPage,
|
|
24
25
|
goPreviousPage = state.goPreviousPage;
|
|
25
26
|
return _objectSpread(_objectSpread({}, component), {}, {
|
|
@@ -29,6 +30,7 @@ function fillFromState(component, state) {
|
|
|
29
30
|
goToPage: goToPage,
|
|
30
31
|
shortcut: shortcut,
|
|
31
32
|
getSuggesterStatus: getSuggesterStatus,
|
|
33
|
+
workersBasePath: workersBasePath,
|
|
32
34
|
goNextPage: goNextPage,
|
|
33
35
|
goPreviousPage: goPreviousPage
|
|
34
36
|
});
|
|
@@ -179,6 +179,21 @@ var LunaticVariablesStore = exports.LunaticVariablesStore = /*#__PURE__*/functio
|
|
|
179
179
|
(0, _missingBehaviour.missingBehaviour)(store, source.missingBlock);
|
|
180
180
|
return store;
|
|
181
181
|
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* Create a new store from an object (useful for testing)
|
|
185
|
+
*/
|
|
186
|
+
}, {
|
|
187
|
+
key: "makeFromObject",
|
|
188
|
+
value: function makeFromObject() {
|
|
189
|
+
var values = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
|
|
190
|
+
var store = new LunaticVariablesStore();
|
|
191
|
+
for (var _i = 0, _Object$keys = Object.keys(values); _i < _Object$keys.length; _i++) {
|
|
192
|
+
var name = _Object$keys[_i];
|
|
193
|
+
store.set(name, values[name]);
|
|
194
|
+
}
|
|
195
|
+
return store;
|
|
196
|
+
}
|
|
182
197
|
}]);
|
|
183
198
|
return LunaticVariablesStore;
|
|
184
199
|
}();
|
|
@@ -14,7 +14,15 @@ var _missingBehaviour = require("./behaviours/missing-behaviour");
|
|
|
14
14
|
variables.set('FIRSTNAME', 'John');
|
|
15
15
|
(0, _vitest.expect)(variables.get('FIRSTNAME')).toEqual('John');
|
|
16
16
|
});
|
|
17
|
-
(0, _vitest.it)('should
|
|
17
|
+
(0, _vitest.it)('should create a store from an object', function () {
|
|
18
|
+
var store = _lunaticVariablesStore.LunaticVariablesStore.makeFromObject({
|
|
19
|
+
name: 'John',
|
|
20
|
+
lastname: 'Doe'
|
|
21
|
+
});
|
|
22
|
+
(0, _vitest.expect)(store.get('name')).toEqual('John');
|
|
23
|
+
(0, _vitest.expect)(store.get('lastname')).toEqual('Doe');
|
|
24
|
+
});
|
|
25
|
+
(0, _vitest.it)('should run with simple types', function () {
|
|
18
26
|
(0, _vitest.expect)(variables.run('"Hello world"')).toEqual('Hello world');
|
|
19
27
|
(0, _vitest.expect)(variables.run('true')).toEqual(true);
|
|
20
28
|
(0, _vitest.expect)(variables.run('2')).toEqual(2);
|
|
@@ -65,7 +65,8 @@ function reduceOnInit(state, action) {
|
|
|
65
65
|
activeControls = payload.activeControls,
|
|
66
66
|
goToPage = payload.goToPage,
|
|
67
67
|
goNextPage = payload.goNextPage,
|
|
68
|
-
goPreviousPage = payload.goPreviousPage
|
|
68
|
+
goPreviousPage = payload.goPreviousPage,
|
|
69
|
+
workersBasePath = payload.workersBasePath;
|
|
69
70
|
if (!source || !data) {
|
|
70
71
|
return state;
|
|
71
72
|
}
|
|
@@ -139,7 +140,8 @@ function reduceOnInit(state, action) {
|
|
|
139
140
|
goToPage: goToPage,
|
|
140
141
|
goNextPage: goNextPage,
|
|
141
142
|
goPreviousPage: goPreviousPage,
|
|
142
|
-
shortcut: shortcut
|
|
143
|
+
shortcut: shortcut,
|
|
144
|
+
workersBasePath: workersBasePath
|
|
143
145
|
}), initialPager);
|
|
144
146
|
}
|
|
145
147
|
var reducers = (0, _compose["default"])(reduceOnInit, _overviewOnInit.reduceOverviewOnInit);
|
|
@@ -78,6 +78,8 @@ function useLunatic(source) {
|
|
|
78
78
|
dontKnowButton = _ref$dontKnowButton === void 0 ? DEFAULT_DONT_KNOW : _ref$dontKnowButton,
|
|
79
79
|
_ref$refusedButton = _ref.refusedButton,
|
|
80
80
|
refusedButton = _ref$refusedButton === void 0 ? DEFAULT_REFUSED : _ref$refusedButton,
|
|
81
|
+
_ref$workersBasePath = _ref.workersBasePath,
|
|
82
|
+
workersBasePath = _ref$workersBasePath === void 0 ? undefined : _ref$workersBasePath,
|
|
81
83
|
_ref$trackChanges = _ref.trackChanges,
|
|
82
84
|
trackChanges = _ref$trackChanges === void 0 ? false : _ref$trackChanges;
|
|
83
85
|
var _useReducer = (0, _react.useReducer)(_reducer["default"], _initialState["default"]),
|
|
@@ -109,7 +111,8 @@ function useLunatic(source) {
|
|
|
109
111
|
var getSuggesterStatus = (0, _useSuggesters.useSuggesters)({
|
|
110
112
|
auto: autoSuggesterLoading,
|
|
111
113
|
getReferentiel: getReferentiel,
|
|
112
|
-
suggesters: suggesters
|
|
114
|
+
suggesters: suggesters,
|
|
115
|
+
workersBasePath: workersBasePath
|
|
113
116
|
});
|
|
114
117
|
var compileControls = (0, _react.useCallback)(function () {
|
|
115
118
|
return (0, _compileControls.compileControls)({
|
|
@@ -183,9 +186,10 @@ function useLunatic(source) {
|
|
|
183
186
|
goToPage: goToPage,
|
|
184
187
|
goNextPage: goNextPage,
|
|
185
188
|
goPreviousPage: goPreviousPage,
|
|
186
|
-
withOverview: withOverview
|
|
189
|
+
withOverview: withOverview,
|
|
190
|
+
workersBasePath: workersBasePath
|
|
187
191
|
}));
|
|
188
|
-
}, [source, data, initialPage, features, preferences, savingType, management, shortcut, handleChange, activeControls, withOverview, goToPage, goNextPage, goPreviousPage, lastReachedPage]);
|
|
192
|
+
}, [source, data, initialPage, features, preferences, savingType, management, shortcut, handleChange, activeControls, withOverview, goToPage, goNextPage, goPreviousPage, lastReachedPage, workersBasePath]);
|
|
189
193
|
(0, _react.useEffect)(function () {
|
|
190
194
|
dispatch(actions.updateState({
|
|
191
195
|
getSuggesterStatus: getSuggesterStatus
|
|
@@ -34,8 +34,14 @@ var SuggesterStatus = exports.SuggesterStatus = /*#__PURE__*/function (Suggester
|
|
|
34
34
|
}({});
|
|
35
35
|
function nothing() {}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
/**
|
|
38
|
+
* Update the status ref
|
|
39
|
+
*/
|
|
40
|
+
function setStatus(status,
|
|
41
|
+
// Name of the referentiel
|
|
42
|
+
name,
|
|
43
|
+
// New state
|
|
44
|
+
state) {
|
|
39
45
|
if (status && status.current) {
|
|
40
46
|
var current = status.current;
|
|
41
47
|
if (name in current) current[name] = state;
|
|
@@ -44,7 +50,8 @@ function setStatus(status, name, state) {
|
|
|
44
50
|
function useSuggesters(_ref) {
|
|
45
51
|
var auto = _ref.auto,
|
|
46
52
|
getReferentiel = _ref.getReferentiel,
|
|
47
|
-
suggesters = _ref.suggesters
|
|
53
|
+
suggesters = _ref.suggesters,
|
|
54
|
+
workersBasePath = _ref.workersBasePath;
|
|
48
55
|
var status = (0, _react.useRef)();
|
|
49
56
|
var _useState = (0, _react.useState)(Date.now()),
|
|
50
57
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -69,37 +76,44 @@ function useSuggesters(_ref) {
|
|
|
69
76
|
timestamp: timestamp
|
|
70
77
|
};
|
|
71
78
|
}, [status, timestamp, auto]);
|
|
79
|
+
|
|
80
|
+
// Make all status "idle"
|
|
72
81
|
(0, _react.useEffect)(function () {
|
|
73
|
-
if (suggesters) {
|
|
74
|
-
|
|
75
|
-
var name = _ref2.name;
|
|
76
|
-
return _objectSpread(_objectSpread({}, a), {}, _defineProperty({}, name, SuggesterStatus.idle));
|
|
77
|
-
}, {});
|
|
82
|
+
if (!suggesters) {
|
|
83
|
+
return;
|
|
78
84
|
}
|
|
85
|
+
status.current = suggesters.reduce(function (a, _ref2) {
|
|
86
|
+
var name = _ref2.name;
|
|
87
|
+
return _objectSpread(_objectSpread({}, a), {}, _defineProperty({}, name, SuggesterStatus.idle));
|
|
88
|
+
}, {});
|
|
79
89
|
}, [suggesters, status]);
|
|
90
|
+
|
|
91
|
+
// Index the data
|
|
80
92
|
(0, _react.useEffect)(function () {
|
|
81
93
|
var aborts = [];
|
|
82
94
|
if (typeof getReferentiel === 'function' && Array.isArray(suggesters) && auto) {
|
|
83
|
-
suggesters.forEach(function (
|
|
84
|
-
var
|
|
85
|
-
|
|
86
|
-
_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
87
|
-
var isClean, data, _createAppendTask, _createAppendTask2, append, abort, result;
|
|
95
|
+
suggesters.forEach( /*#__PURE__*/function () {
|
|
96
|
+
var _ref3 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(store) {
|
|
97
|
+
var name, current, isClean, data, _createAppendTask, _createAppendTask2, append, abort, result;
|
|
88
98
|
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
89
99
|
while (1) switch (_context.prev = _context.next) {
|
|
90
100
|
case 0:
|
|
91
|
-
|
|
92
|
-
|
|
101
|
+
name = store.name;
|
|
102
|
+
current = status.current;
|
|
103
|
+
if (current) {
|
|
104
|
+
_context.next = 4;
|
|
93
105
|
break;
|
|
94
106
|
}
|
|
95
|
-
_context.
|
|
107
|
+
return _context.abrupt("return");
|
|
108
|
+
case 4:
|
|
109
|
+
_context.prev = 4;
|
|
96
110
|
if (!(current[name] === SuggesterStatus.idle)) {
|
|
97
|
-
_context.next =
|
|
111
|
+
_context.next = 10;
|
|
98
112
|
break;
|
|
99
113
|
}
|
|
100
|
-
_context.next =
|
|
114
|
+
_context.next = 8;
|
|
101
115
|
return (0, _initStore.initStore)(store);
|
|
102
|
-
case
|
|
116
|
+
case 8:
|
|
103
117
|
isClean = _context.sent;
|
|
104
118
|
if (!isClean) {
|
|
105
119
|
setStatus(status, name, SuggesterStatus.error);
|
|
@@ -108,20 +122,20 @@ function useSuggesters(_ref) {
|
|
|
108
122
|
setStatus(status, name, SuggesterStatus.pending);
|
|
109
123
|
setTimestamp(Date.now());
|
|
110
124
|
}
|
|
111
|
-
case
|
|
125
|
+
case 10:
|
|
112
126
|
if (!(current[name] === SuggesterStatus.pending)) {
|
|
113
|
-
_context.next =
|
|
127
|
+
_context.next = 20;
|
|
114
128
|
break;
|
|
115
129
|
}
|
|
116
|
-
_context.next =
|
|
130
|
+
_context.next = 13;
|
|
117
131
|
return getReferentiel(name);
|
|
118
|
-
case
|
|
132
|
+
case 13:
|
|
119
133
|
data = _context.sent;
|
|
120
|
-
_createAppendTask = (0, _createAppendTask3.createAppendTask)(store, 1, nothing), _createAppendTask2 = _slicedToArray(_createAppendTask, 2), append = _createAppendTask2[0], abort = _createAppendTask2[1];
|
|
134
|
+
_createAppendTask = (0, _createAppendTask3.createAppendTask)(store, 1, nothing, workersBasePath), _createAppendTask2 = _slicedToArray(_createAppendTask, 2), append = _createAppendTask2[0], abort = _createAppendTask2[1];
|
|
121
135
|
aborts.push(abort);
|
|
122
|
-
_context.next =
|
|
136
|
+
_context.next = 18;
|
|
123
137
|
return append(data);
|
|
124
|
-
case
|
|
138
|
+
case 18:
|
|
125
139
|
result = _context.sent;
|
|
126
140
|
if (result) {
|
|
127
141
|
setStatus(status, name, SuggesterStatus.success);
|
|
@@ -130,28 +144,31 @@ function useSuggesters(_ref) {
|
|
|
130
144
|
setStatus(status, name, SuggesterStatus.error);
|
|
131
145
|
setTimestamp(Date.now());
|
|
132
146
|
}
|
|
133
|
-
case
|
|
134
|
-
_context.next =
|
|
147
|
+
case 20:
|
|
148
|
+
_context.next = 27;
|
|
135
149
|
break;
|
|
136
|
-
case
|
|
137
|
-
_context.prev =
|
|
138
|
-
_context.t0 = _context["catch"](
|
|
150
|
+
case 22:
|
|
151
|
+
_context.prev = 22;
|
|
152
|
+
_context.t0 = _context["catch"](4);
|
|
139
153
|
console.error(_context.t0);
|
|
140
154
|
setStatus(status, name, SuggesterStatus.error);
|
|
141
155
|
setTimestamp(Date.now());
|
|
142
|
-
case
|
|
156
|
+
case 27:
|
|
143
157
|
case "end":
|
|
144
158
|
return _context.stop();
|
|
145
159
|
}
|
|
146
|
-
}, _callee, null, [[
|
|
147
|
-
}))
|
|
148
|
-
|
|
160
|
+
}, _callee, null, [[4, 22]]);
|
|
161
|
+
}));
|
|
162
|
+
return function (_x) {
|
|
163
|
+
return _ref3.apply(this, arguments);
|
|
164
|
+
};
|
|
165
|
+
}());
|
|
149
166
|
return function () {
|
|
150
|
-
aborts.forEach(function (
|
|
151
|
-
|
|
167
|
+
aborts.forEach(function (abort) {
|
|
168
|
+
return abort();
|
|
152
169
|
});
|
|
153
170
|
};
|
|
154
171
|
}
|
|
155
|
-
}, [suggesters, auto, getReferentiel, status]);
|
|
172
|
+
}, [suggesters, auto, getReferentiel, status, workersBasePath]);
|
|
156
173
|
return getSuggesterStatus;
|
|
157
174
|
}
|
package/lib/utils/env.js
CHANGED
|
@@ -5,5 +5,13 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.isTestEnv = isTestEnv;
|
|
7
7
|
function isTestEnv() {
|
|
8
|
-
|
|
8
|
+
try {
|
|
9
|
+
// using vitest, process.env is defined
|
|
10
|
+
return /test/.test("".concat(process.env.npm_lifecycle_event));
|
|
11
|
+
} catch (e) {
|
|
12
|
+
// process.env is not defined
|
|
13
|
+
// so we are not running as test so we can return false
|
|
14
|
+
// process.env is not defined during storybook running/
|
|
15
|
+
return false;
|
|
16
|
+
}
|
|
9
17
|
}
|
|
@@ -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 _createWorker = require("../create-worker");
|
|
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];
|
|
@@ -17,15 +17,16 @@ function consoleLogging() {
|
|
|
17
17
|
}
|
|
18
18
|
|
|
19
19
|
/**
|
|
20
|
-
*
|
|
20
|
+
* Creates methods to communicate with workers for indexing data
|
|
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,
|
|
29
|
+
var worker = (0, _createWorker.createWorker)((0, _workerPath.getWorkerPath)(_workerPath.WorkerEnum.APPEND, workersBasePath));
|
|
29
30
|
var start = false;
|
|
30
31
|
var stop = false;
|
|
31
32
|
function launch(entities) {
|