@inseefr/lunatic 2.5.0-beta → 2.5.0-fast-forward
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/src/use-lunatic/actions.d.ts +2 -0
- package/lib/src/use-lunatic/reducer/reduce-on-init.d.ts +1 -1
- package/lib/src/use-lunatic/use-lunatic.d.ts +4 -3
- package/lib/stories/loop/roster-for-loop.stories.js +85 -2
- package/lib/stories/utils/orchestrator.js +16 -3
- package/lib/use-lunatic/reducer/commons/auto-explore-loop.js +1 -3
- package/lib/use-lunatic/reducer/reduce-go-to-page.js +1 -3
- package/lib/use-lunatic/reducer/reduce-on-init.js +3 -2
- package/lib/use-lunatic/use-lunatic.js +5 -1
- package/lib/use-lunatic/use-lunatic.test.js +9 -7
- package/package.json +1 -1
|
@@ -41,6 +41,7 @@ export type ActionInit = {
|
|
|
41
41
|
data: LunaticData;
|
|
42
42
|
source: LunaticSource;
|
|
43
43
|
initialPage: string;
|
|
44
|
+
lastReachedPage: string;
|
|
44
45
|
features: LunaticState['features'];
|
|
45
46
|
preferences: LunaticState['preferences'];
|
|
46
47
|
savingType: LunaticState['savingType'];
|
|
@@ -102,6 +103,7 @@ export declare const onInit: (payload: {
|
|
|
102
103
|
data: LunaticData;
|
|
103
104
|
source: LunaticSource;
|
|
104
105
|
initialPage: string;
|
|
106
|
+
lastReachedPage: string;
|
|
105
107
|
features: LunaticState['features'];
|
|
106
108
|
preferences: LunaticState['preferences'];
|
|
107
109
|
savingType: LunaticState['savingType'];
|
|
@@ -5,7 +5,7 @@ import { LunaticComponentType } from '../components/type';
|
|
|
5
5
|
declare const nothing: LunaticState['handleChange'];
|
|
6
6
|
declare function useLunatic(source: LunaticSource, data: Partial<Record<"EXTERNAL" | "CALCULATED", Record<string, unknown>> & {
|
|
7
7
|
COLLECTED: Record<string, import("./type").LunaticCollectedValue>;
|
|
8
|
-
}> | undefined, { features, preferences, savingType, onChange, management, shortcut, initialPage, autoSuggesterLoading, activeControls, getReferentiel, custom, withOverview, missing, missingStrategy, missingShortcut, dontKnowButton, refusedButton, }: {
|
|
8
|
+
}> | undefined, { features, preferences, savingType, onChange, management, shortcut, initialPage, lastReachedPage, autoSuggesterLoading, activeControls, getReferentiel, custom, withOverview, missing, missingStrategy, missingShortcut, dontKnowButton, refusedButton, }: {
|
|
9
9
|
features?: LunaticState['features'];
|
|
10
10
|
preferences?: LunaticState['preferences'];
|
|
11
11
|
savingType?: LunaticState['savingType'];
|
|
@@ -13,6 +13,7 @@ declare function useLunatic(source: LunaticSource, data: Partial<Record<"EXTERNA
|
|
|
13
13
|
management?: boolean;
|
|
14
14
|
shortcut?: boolean;
|
|
15
15
|
initialPage?: string;
|
|
16
|
+
lastReachedPage?: string;
|
|
16
17
|
autoSuggesterLoading?: boolean;
|
|
17
18
|
getReferentiel?: (name: string) => Promise<Array<unknown>>;
|
|
18
19
|
activeControls?: boolean;
|
|
@@ -257,7 +258,7 @@ declare function useLunatic(source: LunaticSource, data: Partial<Record<"EXTERNA
|
|
|
257
258
|
}[];
|
|
258
259
|
};
|
|
259
260
|
})[] | undefined;
|
|
260
|
-
except?: keyof {
|
|
261
|
+
except?: (keyof {
|
|
261
262
|
InputNumber: import("../components/type").LunaticBaseProps<number | null> & {
|
|
262
263
|
min: number;
|
|
263
264
|
max: number;
|
|
@@ -485,7 +486,7 @@ declare function useLunatic(source: LunaticSource, data: Partial<Record<"EXTERNA
|
|
|
485
486
|
iterations?: number | undefined;
|
|
486
487
|
}[];
|
|
487
488
|
};
|
|
488
|
-
} | undefined;
|
|
489
|
+
})[] | undefined;
|
|
489
490
|
}) => import("./commons/fill-components/fill-components").LunaticComponentProps<"Sequence" | "Subsequence" | "RosterForLoop" | "Loop" | "Table" | "Input" | "InputNumber" | "Datepicker" | "CheckboxGroup" | "CheckboxOne" | "CheckboxBoolean" | "Radio" | "Dropdown" | "Textarea" | "FilterDescription" | "PairwiseLinks" | "Suggester" | "ComponentSet" | "Roundabout" | "QuestionExplication">[];
|
|
490
491
|
goPreviousPage: () => void;
|
|
491
492
|
goNextPage: (payload?: {}) => void;
|
|
@@ -3,14 +3,19 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports["default"] = exports.ReadOnly = exports.Default = void 0;
|
|
6
|
+
exports["default"] = exports.ReadOnly = exports.Filled = exports.Default = void 0;
|
|
7
7
|
var _react = _interopRequireDefault(require("react"));
|
|
8
8
|
var _orchestrator = _interopRequireDefault(require("../utils/orchestrator"));
|
|
9
9
|
var _sourceRoster = _interopRequireDefault(require("./source-roster"));
|
|
10
10
|
var _defaultArgTypes = _interopRequireDefault(require("../utils/default-arg-types"));
|
|
11
|
+
var _e2e = require("../../../tests/utils/e2e");
|
|
12
|
+
var _timer = require("../../../tests/utils/timer");
|
|
11
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
15
|
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); }
|
|
16
|
+
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; }
|
|
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); }); }; }
|
|
14
19
|
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
20
|
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
21
|
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; }
|
|
@@ -38,4 +43,82 @@ ReadOnly.args = {
|
|
|
38
43
|
id: 'roster-for-loop',
|
|
39
44
|
source: _sourceRoster["default"],
|
|
40
45
|
readOnly: true
|
|
41
|
-
};
|
|
46
|
+
};
|
|
47
|
+
var Filled = Template.bind({});
|
|
48
|
+
exports.Filled = Filled;
|
|
49
|
+
Filled.args = {
|
|
50
|
+
id: 'roster-for-loop',
|
|
51
|
+
source: _sourceRoster["default"]
|
|
52
|
+
};
|
|
53
|
+
Filled.play = /*#__PURE__*/function () {
|
|
54
|
+
var _ref2 = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(_ref) {
|
|
55
|
+
var args, canvasElement, page;
|
|
56
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
57
|
+
while (1) switch (_context.prev = _context.next) {
|
|
58
|
+
case 0:
|
|
59
|
+
args = _ref.args, canvasElement = _ref.canvasElement;
|
|
60
|
+
page = (0, _e2e.playwrightToUserEvent)(canvasElement);
|
|
61
|
+
_context.next = 4;
|
|
62
|
+
return (0, _timer.sleep)(100);
|
|
63
|
+
case 4:
|
|
64
|
+
_context.next = 6;
|
|
65
|
+
return page.getByRole('button', {
|
|
66
|
+
name: 'Ajouter un individu'
|
|
67
|
+
}).click();
|
|
68
|
+
case 6:
|
|
69
|
+
_context.next = 8;
|
|
70
|
+
return page.getByLabel('Prénom', {
|
|
71
|
+
index: 0
|
|
72
|
+
}).fill('John');
|
|
73
|
+
case 8:
|
|
74
|
+
_context.next = 10;
|
|
75
|
+
return page.getByLabel('Prénom', {
|
|
76
|
+
index: 1
|
|
77
|
+
}).fill('Jane');
|
|
78
|
+
case 10:
|
|
79
|
+
_context.next = 12;
|
|
80
|
+
return page.getByRole('button', {
|
|
81
|
+
name: 'Next'
|
|
82
|
+
}).click();
|
|
83
|
+
case 12:
|
|
84
|
+
_context.next = 14;
|
|
85
|
+
return page.getByLabel('John, quel est vôtre âge ?').fill('18');
|
|
86
|
+
case 14:
|
|
87
|
+
_context.next = 16;
|
|
88
|
+
return page.getByRole('button', {
|
|
89
|
+
name: 'Next'
|
|
90
|
+
}).click();
|
|
91
|
+
case 16:
|
|
92
|
+
_context.next = 18;
|
|
93
|
+
return page.getByLabel('Jane, quel est vôtre âge ?').fill('21');
|
|
94
|
+
case 18:
|
|
95
|
+
_context.next = 20;
|
|
96
|
+
return page.getByLabel(/Page/).fill('2.1#1');
|
|
97
|
+
case 20:
|
|
98
|
+
_context.next = 22;
|
|
99
|
+
return page.getByRole('button', {
|
|
100
|
+
name: /Go to page/
|
|
101
|
+
}).click();
|
|
102
|
+
case 22:
|
|
103
|
+
_context.next = 24;
|
|
104
|
+
return page.getByRole('button', {
|
|
105
|
+
name: 'Next'
|
|
106
|
+
}).click();
|
|
107
|
+
case 24:
|
|
108
|
+
_context.next = 26;
|
|
109
|
+
return page.getByRole('button', {
|
|
110
|
+
name: 'Next'
|
|
111
|
+
}).click();
|
|
112
|
+
case 26:
|
|
113
|
+
_context.next = 28;
|
|
114
|
+
return page.getByText('End').shouldBeVisible();
|
|
115
|
+
case 28:
|
|
116
|
+
case "end":
|
|
117
|
+
return _context.stop();
|
|
118
|
+
}
|
|
119
|
+
}, _callee);
|
|
120
|
+
}));
|
|
121
|
+
return function (_x) {
|
|
122
|
+
return _ref2.apply(this, arguments);
|
|
123
|
+
};
|
|
124
|
+
}();
|
|
@@ -9,9 +9,9 @@ require("./custom-lunatic.scss");
|
|
|
9
9
|
require("./orchestrator.scss");
|
|
10
10
|
var lunatic = _interopRequireWildcard(require("../.."));
|
|
11
11
|
var _react = _interopRequireWildcard(require("react"));
|
|
12
|
+
var _logger = require("../../utils/logger");
|
|
12
13
|
var _overview = require("./overview");
|
|
13
14
|
var _waiting = _interopRequireDefault(require("./waiting"));
|
|
14
|
-
var _logger = require("../../utils/logger");
|
|
15
15
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
16
16
|
var _excluded = ["source", "data", "management", "shortcut", "activeControls", "features", "initialPage", "getStoreInfo", "missing", "missingStrategy", "missingShortcut", "autoSuggesterLoading", "addExternal", "preferences", "custom", "showOverview", "filterDescription", "getReferentiel", "dontKnowButton", "refusedButton", "readOnly"],
|
|
17
17
|
_excluded2 = ["id", "componentType", "response", "storeName", "conditionFilter"];
|
|
@@ -36,7 +36,8 @@ function getStoreInfoRequired() {
|
|
|
36
36
|
}
|
|
37
37
|
function DevOptions(_ref) {
|
|
38
38
|
var goToPage = _ref.goToPage,
|
|
39
|
-
getData = _ref.getData
|
|
39
|
+
getData = _ref.getData,
|
|
40
|
+
lastReachedPage = _ref.lastReachedPage;
|
|
40
41
|
var _useState = (0, _react.useState)(1),
|
|
41
42
|
_useState2 = _slicedToArray(_useState, 2),
|
|
42
43
|
toPage = _useState2[0],
|
|
@@ -63,6 +64,13 @@ function DevOptions(_ref) {
|
|
|
63
64
|
});
|
|
64
65
|
},
|
|
65
66
|
children: "Go to page ".concat(toPage)
|
|
67
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(lunatic.Button, {
|
|
68
|
+
onClick: function onClick() {
|
|
69
|
+
return goToPage({
|
|
70
|
+
page: "".concat(lastReachedPage)
|
|
71
|
+
});
|
|
72
|
+
},
|
|
73
|
+
children: "Go to lastReachedPage : ".concat(lastReachedPage)
|
|
66
74
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(lunatic.Input, {
|
|
67
75
|
id: "page-to-jump",
|
|
68
76
|
value: toPage,
|
|
@@ -78,6 +86,7 @@ function Pager(_ref2) {
|
|
|
78
86
|
var goPrevious = _ref2.goPrevious,
|
|
79
87
|
goNext = _ref2.goNext,
|
|
80
88
|
goToPage = _ref2.goToPage,
|
|
89
|
+
lastReachedPage = _ref2.lastReachedPage,
|
|
81
90
|
isLast = _ref2.isLast,
|
|
82
91
|
isFirst = _ref2.isFirst,
|
|
83
92
|
pageTag = _ref2.pageTag,
|
|
@@ -101,7 +110,8 @@ function Pager(_ref2) {
|
|
|
101
110
|
children: ["PAGE: ", pageTag]
|
|
102
111
|
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(DevOptions, {
|
|
103
112
|
goToPage: goToPage,
|
|
104
|
-
getData: getData
|
|
113
|
+
getData: getData,
|
|
114
|
+
lastReachedPage: lastReachedPage
|
|
105
115
|
})]
|
|
106
116
|
});
|
|
107
117
|
}
|
|
@@ -172,6 +182,7 @@ function OrchestratorForStories(_ref3) {
|
|
|
172
182
|
goPreviousPage = _lunatic$useLunatic.goPreviousPage,
|
|
173
183
|
goNextPage = _lunatic$useLunatic.goNextPage,
|
|
174
184
|
goToPage = _lunatic$useLunatic.goToPage,
|
|
185
|
+
pager = _lunatic$useLunatic.pager,
|
|
175
186
|
pageTag = _lunatic$useLunatic.pageTag,
|
|
176
187
|
isFirstPage = _lunatic$useLunatic.isFirstPage,
|
|
177
188
|
isLastPage = _lunatic$useLunatic.isLastPage,
|
|
@@ -181,6 +192,7 @@ function OrchestratorForStories(_ref3) {
|
|
|
181
192
|
getData = _lunatic$useLunatic.getData,
|
|
182
193
|
Provider = _lunatic$useLunatic.Provider;
|
|
183
194
|
var components = getComponents();
|
|
195
|
+
var lastReachedPage = pager.lastReachedPage;
|
|
184
196
|
var _useState3 = (0, _react.useState)({}),
|
|
185
197
|
_useState4 = _slicedToArray(_useState3, 2),
|
|
186
198
|
errorActive = _useState4[0],
|
|
@@ -239,6 +251,7 @@ function OrchestratorForStories(_ref3) {
|
|
|
239
251
|
goPrevious: goPreviousPage,
|
|
240
252
|
goNext: handleGoNext,
|
|
241
253
|
goToPage: goToPage,
|
|
254
|
+
lastReachedPage: lastReachedPage,
|
|
242
255
|
isLast: isLastPage,
|
|
243
256
|
isFirst: isFirstPage,
|
|
244
257
|
pageTag: pageTag,
|
|
@@ -27,9 +27,7 @@ function autoExploreLoop(state) {
|
|
|
27
27
|
newPager.page = firstSubPage[0].toString();
|
|
28
28
|
newPager.subPage = firstSubPage[1] - 1; // Subpage starts at 0
|
|
29
29
|
newPager.nbSubPages = maxSubPage;
|
|
30
|
-
newPager.nbIterations = state.executeExpression(page.iterations
|
|
31
|
-
iteration: newPager.iteration
|
|
32
|
-
});
|
|
30
|
+
newPager.nbIterations = state.executeExpression(page.iterations);
|
|
33
31
|
newPager.iteration = isForward ? 0 : newPager.nbIterations - 1;
|
|
34
32
|
}
|
|
35
33
|
return _objectSpread(_objectSpread({}, state), {}, {
|
|
@@ -51,9 +51,7 @@ function reduceGoToPage(state, action) {
|
|
|
51
51
|
if (action.payload.subPage !== undefined) {
|
|
52
52
|
var _parentPage$subPages;
|
|
53
53
|
newPager.nbSubPages = (_parentPage$subPages = parentPage.subPages) === null || _parentPage$subPages === void 0 ? void 0 : _parentPage$subPages.length;
|
|
54
|
-
newPager.nbIterations = state.executeExpression(parentPage.iterations
|
|
55
|
-
iteration: newPager.iteration
|
|
56
|
-
});
|
|
54
|
+
newPager.nbIterations = state.executeExpression(parentPage.iterations);
|
|
57
55
|
}
|
|
58
56
|
|
|
59
57
|
// Prevent an out of bound iteration
|
|
@@ -5,8 +5,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
7
|
var _commons = require("../commons");
|
|
8
|
-
var _pageTag = require("../commons/page-tag");
|
|
9
8
|
var _compose = _interopRequireDefault(require("../commons/compose"));
|
|
9
|
+
var _pageTag = require("../commons/page-tag");
|
|
10
10
|
var _overviewOnInit = require("./overview/overview-on-init");
|
|
11
11
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
12
|
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
@@ -171,6 +171,7 @@ function reduceOnInit(state, action) {
|
|
|
171
171
|
var source = payload.source,
|
|
172
172
|
data = payload.data,
|
|
173
173
|
initialPage = payload.initialPage,
|
|
174
|
+
lastReachedPage = payload.lastReachedPage,
|
|
174
175
|
features = payload.features,
|
|
175
176
|
handleChange = payload.handleChange,
|
|
176
177
|
preferences = payload.preferences,
|
|
@@ -202,7 +203,7 @@ function reduceOnInit(state, action) {
|
|
|
202
203
|
nbSubPages: undefined,
|
|
203
204
|
iteration: undefined,
|
|
204
205
|
nbIterations: undefined,
|
|
205
|
-
lastReachedPage:
|
|
206
|
+
lastReachedPage: lastReachedPage
|
|
206
207
|
};
|
|
207
208
|
var _isFirstLastPage = (0, _commons.isFirstLastPage)(pager),
|
|
208
209
|
isFirstPage = _isFirstLastPage.isFirstPage,
|
|
@@ -56,6 +56,8 @@ function useLunatic(source) {
|
|
|
56
56
|
shortcut = _ref$shortcut === void 0 ? false : _ref$shortcut,
|
|
57
57
|
_ref$initialPage = _ref.initialPage,
|
|
58
58
|
initialPage = _ref$initialPage === void 0 ? '1' : _ref$initialPage,
|
|
59
|
+
_ref$lastReachedPage = _ref.lastReachedPage,
|
|
60
|
+
lastReachedPage = _ref$lastReachedPage === void 0 ? '1' : _ref$lastReachedPage,
|
|
59
61
|
_ref$autoSuggesterLoa = _ref.autoSuggesterLoading,
|
|
60
62
|
autoSuggesterLoading = _ref$autoSuggesterLoa === void 0 ? false : _ref$autoSuggesterLoa,
|
|
61
63
|
_ref$activeControls = _ref.activeControls,
|
|
@@ -161,11 +163,13 @@ function useLunatic(source) {
|
|
|
161
163
|
var _isFirstLastPage = (0, _commons.isFirstLastPage)(pager),
|
|
162
164
|
isFirstPage = _isFirstLastPage.isFirstPage,
|
|
163
165
|
isLastPage = _isFirstLastPage.isLastPage;
|
|
166
|
+
console.log('State overview', state.overview);
|
|
164
167
|
(0, _react.useEffect)(function () {
|
|
165
168
|
dispatch(actions.onInit({
|
|
166
169
|
source: source,
|
|
167
170
|
data: data,
|
|
168
171
|
initialPage: initialPage,
|
|
172
|
+
lastReachedPage: lastReachedPage,
|
|
169
173
|
features: features,
|
|
170
174
|
preferences: preferences,
|
|
171
175
|
savingType: savingType,
|
|
@@ -176,7 +180,7 @@ function useLunatic(source) {
|
|
|
176
180
|
goToPage: goToPage,
|
|
177
181
|
withOverview: withOverview
|
|
178
182
|
}));
|
|
179
|
-
}, [source, data, initialPage, features, preferences, savingType, management, shortcut, handleChange, activeControls, withOverview, goToPage]);
|
|
183
|
+
}, [source, data, initialPage, features, preferences, savingType, management, shortcut, handleChange, activeControls, withOverview, goToPage, lastReachedPage]);
|
|
180
184
|
(0, _react.useEffect)(function () {
|
|
181
185
|
dispatch(actions.updateState({
|
|
182
186
|
getSuggesterStatus: getSuggesterStatus
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
var _vitest = require("vitest");
|
|
4
3
|
var _reactHooks = require("@testing-library/react-hooks");
|
|
4
|
+
var _vitest = require("vitest");
|
|
5
5
|
var _useLunatic = _interopRequireDefault(require("./use-lunatic"));
|
|
6
|
-
var _source = _interopRequireDefault(require("../stories/
|
|
6
|
+
var _source = _interopRequireDefault(require("../stories/overview/source.json"));
|
|
7
7
|
var _source2 = _interopRequireDefault(require("../stories/questionnaires/logement/source.json"));
|
|
8
|
-
var _source3 = _interopRequireDefault(require("../stories/
|
|
8
|
+
var _source3 = _interopRequireDefault(require("../stories/questionnaires/simpsons/source.json"));
|
|
9
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
10
|
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); }
|
|
11
11
|
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; }
|
|
@@ -29,7 +29,7 @@ var dataFromObject = function dataFromObject(o) {
|
|
|
29
29
|
};
|
|
30
30
|
};
|
|
31
31
|
(0, _vitest.describe)('use-lunatic()', function () {
|
|
32
|
-
var defaultParams = [
|
|
32
|
+
var defaultParams = [_source3["default"], dataFromObject({}), {}];
|
|
33
33
|
(0, _vitest.it)('should initialize correcly', function () {
|
|
34
34
|
var _renderHook = (0, _reactHooks.renderHook)(function () {
|
|
35
35
|
return _useLunatic["default"].apply(void 0, defaultParams);
|
|
@@ -53,7 +53,7 @@ var dataFromObject = function dataFromObject(o) {
|
|
|
53
53
|
(0, _vitest.expect)(result.current.pager.lastReachedPage).toBe('2');
|
|
54
54
|
});
|
|
55
55
|
(0, _vitest.it)('should jump to a specific page', function () {
|
|
56
|
-
var params = [
|
|
56
|
+
var params = [_source3["default"], dataFromObject({
|
|
57
57
|
COMMENT: 'Hello world',
|
|
58
58
|
READY: true,
|
|
59
59
|
NAME_CHAR: ['a', 'b']
|
|
@@ -142,7 +142,7 @@ var dataFromObject = function dataFromObject(o) {
|
|
|
142
142
|
});
|
|
143
143
|
(0, _vitest.it)('should be empty when no hierarchy', function () {
|
|
144
144
|
var _renderHook8 = (0, _reactHooks.renderHook)(function () {
|
|
145
|
-
return (0, _useLunatic["default"])(
|
|
145
|
+
return (0, _useLunatic["default"])(_source["default"], undefined, lunaticConfiguration);
|
|
146
146
|
}),
|
|
147
147
|
result = _renderHook8.result;
|
|
148
148
|
(0, _vitest.expect)(result.current.overview).toHaveLength(0);
|
|
@@ -152,7 +152,9 @@ var dataFromObject = function dataFromObject(o) {
|
|
|
152
152
|
var _renderHook9 = (0, _reactHooks.renderHook)(function () {
|
|
153
153
|
return (0, _useLunatic["default"])(_source2["default"], advancedQestionnaireData, _objectSpread(_objectSpread({}, lunaticConfiguration), {}, {
|
|
154
154
|
// hack on initialPage : useLunatic SHOULD find lastReachedPage from COLLECTED data
|
|
155
|
-
initialPage: '
|
|
155
|
+
initialPage: '1',
|
|
156
|
+
// use lastReachedPage saved by orchestrator
|
|
157
|
+
lastReachedPage: '16'
|
|
156
158
|
}));
|
|
157
159
|
}),
|
|
158
160
|
result = _renderHook9.result;
|