@inseefr/lunatic 2.7.4 → 2.7.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/commons/components/md-label/link.js +39 -34
- package/lib/components/commons/components/md-label/md-label.js +2 -2
- package/lib/components/commons/components/md-label/md-label.spec.js +71 -0
- package/lib/components/commons/components/md-label/router-link.js +29 -0
- package/lib/components/commons/components/variable-status/variable-status.js +2 -2
- package/lib/components/index.scss +19 -1
- package/lib/hooks/use-auto-focus.js +1 -1
- package/lib/src/components/commons/components/md-label/router-link.d.ts +6 -0
- package/lib/src/use-lunatic/commons/variables/lunatic-variables-store.d.ts +1 -0
- package/lib/src/use-lunatic/hooks/use-page-has-response.d.ts +6 -0
- package/lib/src/use-lunatic/use-lunatic.d.ts +1 -0
- package/lib/src/utils/suggester-workers/searching/meloto-order.d.ts +2 -1
- package/lib/stories/markdown/markdown.stories.js +32 -0
- package/lib/stories/markdown/source.json +40 -0
- package/lib/stories/suggester/suggester-workers.stories.js +36 -1
- package/lib/stories/utils/orchestrator.js +89 -49
- package/lib/stories/utils/orchestrator.scss +49 -0
- package/lib/stories/utils/referentiel.js +8 -4
- package/lib/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js +14 -9
- package/lib/use-lunatic/commons/variables/get-questionnaire-data.js +6 -1
- package/lib/use-lunatic/commons/variables/lunatic-variables-store.js +25 -7
- package/lib/use-lunatic/commons/variables/lunatic-variables-store.spec.js +39 -0
- package/lib/use-lunatic/hooks/use-page-has-response.js +87 -0
- package/lib/use-lunatic/use-lunatic.js +3 -1
- package/lib/utils/env.js +1 -1
- package/lib/utils/suggester-workers/searching/meloto-order.js +6 -5
- package/package.json +2 -2
- package/workers-release/lunatic-search-worker-0.3.0.js +1 -1
|
@@ -4,49 +4,54 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
var
|
|
7
|
+
var _react = require("react");
|
|
8
|
+
var _reactTooltip = require("react-tooltip");
|
|
9
|
+
var _reactMarkdown = _interopRequireDefault(require("react-markdown"));
|
|
10
|
+
var _routerLink = _interopRequireDefault(require("./router-link"));
|
|
8
11
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
9
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
+
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); }
|
|
14
|
+
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; }
|
|
15
|
+
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; }
|
|
16
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
18
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
10
19
|
var Link = function Link(props) {
|
|
11
20
|
var href = props.href,
|
|
12
21
|
children = props.children,
|
|
13
22
|
title = props.title;
|
|
14
|
-
|
|
15
|
-
var
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
};
|
|
27
|
-
};
|
|
28
|
-
if (href.trim().startsWith('http')) return /*#__PURE__*/(0, _jsxRuntime.jsx)("a", {
|
|
23
|
+
var id = (0, _react.useId)();
|
|
24
|
+
var LinkComponent = function () {
|
|
25
|
+
if (href.trim().startsWith('/')) {
|
|
26
|
+
return _routerLink["default"];
|
|
27
|
+
} else {
|
|
28
|
+
return 'a';
|
|
29
|
+
}
|
|
30
|
+
}();
|
|
31
|
+
var linkProps = _objectSpread(_objectSpread({}, href.trim().startsWith('/') ? {
|
|
32
|
+
to: href,
|
|
33
|
+
id: id
|
|
34
|
+
} : {
|
|
29
35
|
href: href,
|
|
30
|
-
target:
|
|
31
|
-
rel:
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
39
|
-
"data-for": "".concat(title, "-tooltip"),
|
|
40
|
-
"data-tip": title,
|
|
41
|
-
"data-multiline": true,
|
|
42
|
-
className: "field-md",
|
|
36
|
+
target: '_blank',
|
|
37
|
+
rel: 'noopener noreferrer',
|
|
38
|
+
id: id
|
|
39
|
+
}), title ? {
|
|
40
|
+
'data-tooltip-id': "tooltip-".concat(id),
|
|
41
|
+
className: 'link-md'
|
|
42
|
+
} : {});
|
|
43
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
|
|
44
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(LinkComponent, _objectSpread(_objectSpread({}, linkProps), {}, {
|
|
43
45
|
children: children
|
|
44
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactTooltip
|
|
45
|
-
id: "".concat(title, "-tooltip"),
|
|
46
|
+
})), title && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactTooltip.Tooltip, {
|
|
46
47
|
className: "tooltip-content",
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
48
|
+
id: "tooltip-".concat(id),
|
|
49
|
+
children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactMarkdown["default"], {
|
|
50
|
+
components: {
|
|
51
|
+
p: _react.Fragment
|
|
52
|
+
},
|
|
53
|
+
children: title
|
|
54
|
+
})
|
|
50
55
|
})]
|
|
51
56
|
});
|
|
52
57
|
};
|
|
@@ -22,10 +22,10 @@ var MdLabel = function MdLabel(_ref) {
|
|
|
22
22
|
_ref$logFunction = _ref.logFunction,
|
|
23
23
|
logFunction = _ref$logFunction === void 0 ? DEFAULT_LOG_FUNCTION : _ref$logFunction;
|
|
24
24
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactMarkdown["default"], {
|
|
25
|
-
children: expression,
|
|
26
25
|
components: renderComponentsFor(expression, {
|
|
27
26
|
logFunction: logFunction
|
|
28
|
-
})
|
|
27
|
+
}),
|
|
28
|
+
children: expression
|
|
29
29
|
});
|
|
30
30
|
};
|
|
31
31
|
var renderComponentsFor = function renderComponentsFor(expression, extraProps) {
|
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
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); }
|
|
3
4
|
var _vitest = require("vitest");
|
|
4
5
|
var _react = require("@testing-library/react");
|
|
6
|
+
var _userEvent = _interopRequireDefault(require("@testing-library/user-event"));
|
|
5
7
|
var _mdLabel = _interopRequireDefault(require("./md-label"));
|
|
6
8
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
7
9
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
10
|
+
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; }
|
|
11
|
+
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); } }
|
|
12
|
+
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); }); }; }
|
|
8
13
|
(0, _vitest.describe)('md-label', function () {
|
|
9
14
|
(0, _vitest.it)('should handle simple text', function () {
|
|
10
15
|
var obj = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_mdLabel["default"], {
|
|
@@ -24,4 +29,70 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
|
|
|
24
29
|
}));
|
|
25
30
|
return (0, _vitest.expect)(obj.container).toMatchInlineSnapshot("\n\t\t\t<div>\n\t\t\t <p>\n\t\t\t This \n\t\t\t <strong>\n\t\t\t is\n\t\t\t </strong>\n\t\t\t a simple test\n\t\t\t </p>\n\t\t\t \n\n\t\t\t <p>\n\t\t\t with multiple paragraphs\n\t\t\t </p>\n\t\t\t</div>\n\t\t");
|
|
26
31
|
});
|
|
32
|
+
(0, _vitest.it)('should render external link', function () {
|
|
33
|
+
var obj = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_mdLabel["default"], {
|
|
34
|
+
expression: 'This is a [link](https://inseefr.github.io/Lunatic/docs)'
|
|
35
|
+
}));
|
|
36
|
+
return (0, _vitest.expect)(obj.container).toMatchInlineSnapshot("\n\t\t\t<div>\n\t\t\t This is a \n\t\t\t <a\n\t\t\t href=\"https://inseefr.github.io/Lunatic/docs\"\n\t\t\t id=\":r0:\"\n\t\t\t rel=\"noopener noreferrer\"\n\t\t\t target=\"_blank\"\n\t\t\t >\n\t\t\t link\n\t\t\t </a>\n\t\t\t</div>\n\t\t");
|
|
37
|
+
});
|
|
38
|
+
(0, _vitest.it)('should render external link with tooltip', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
39
|
+
var _render, container, link, tooltip;
|
|
40
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
41
|
+
while (1) switch (_context.prev = _context.next) {
|
|
42
|
+
case 0:
|
|
43
|
+
_render = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_mdLabel["default"], {
|
|
44
|
+
expression: "This is a [link](https://inseefr.github.io/Lunatic/docs 'with a tooltip')"
|
|
45
|
+
})), container = _render.container;
|
|
46
|
+
link = _react.screen.getByText('link'); // Get the link element by its text content
|
|
47
|
+
// Simulate hover event
|
|
48
|
+
_context.next = 4;
|
|
49
|
+
return _userEvent["default"].hover(link);
|
|
50
|
+
case 4:
|
|
51
|
+
tooltip = null;
|
|
52
|
+
_context.next = 7;
|
|
53
|
+
return (0, _react.waitFor)(function () {
|
|
54
|
+
tooltip = _react.screen.getByRole('tooltip');
|
|
55
|
+
});
|
|
56
|
+
case 7:
|
|
57
|
+
(0, _vitest.expect)(tooltip).toBeInTheDocument();
|
|
58
|
+
(0, _vitest.expect)(container).toMatchInlineSnapshot("\n\t\t\t<div>\n\t\t\t This is a \n\t\t\t <a\n\t\t\t class=\"link-md\"\n\t\t\t data-tooltip-id=\"tooltip-:r1:\"\n\t\t\t href=\"https://inseefr.github.io/Lunatic/docs\"\n\t\t\t id=\":r1:\"\n\t\t\t rel=\"noopener noreferrer\"\n\t\t\t target=\"_blank\"\n\t\t\t >\n\t\t\t link\n\t\t\t </a>\n\t\t\t <div\n\t\t\t class=\"react-tooltip core-styles-module_tooltip__3vRRp styles-module_tooltip__mnnfp styles-module_dark__xNqje tooltip-content react-tooltip__place-top core-styles-module_show__Nt9eE react-tooltip__show\"\n\t\t\t id=\"tooltip-:r1:\"\n\t\t\t role=\"tooltip\"\n\t\t\t style=\"left: 5px; top: -10px;\"\n\t\t\t >\n\t\t\t with a tooltip\n\t\t\t <div\n\t\t\t class=\"react-tooltip-arrow core-styles-module_arrow__cvMwQ styles-module_arrow__K0L3T\"\n\t\t\t style=\"left: -1px; bottom: -4px;\"\n\t\t\t />\n\t\t\t </div>\n\t\t\t</div>\n\t\t");
|
|
59
|
+
case 9:
|
|
60
|
+
case "end":
|
|
61
|
+
return _context.stop();
|
|
62
|
+
}
|
|
63
|
+
}, _callee);
|
|
64
|
+
})));
|
|
65
|
+
(0, _vitest.it)('should render internal link', function () {
|
|
66
|
+
var obj = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_mdLabel["default"], {
|
|
67
|
+
expression: 'This is an [internal link](/docs)'
|
|
68
|
+
}));
|
|
69
|
+
return (0, _vitest.expect)(obj.container).toMatchInlineSnapshot("\n\t\t\t<div>\n\t\t\t This is an \n\t\t\t <a\n\t\t\t href=\"/docs\"\n\t\t\t id=\":r2:\"\n\t\t\t >\n\t\t\t internal link\n\t\t\t </a>\n\t\t\t</div>\n\t\t");
|
|
70
|
+
});
|
|
71
|
+
(0, _vitest.it)('should render internal link with tooltip', /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2() {
|
|
72
|
+
var _render2, container, link, tooltip;
|
|
73
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
74
|
+
while (1) switch (_context2.prev = _context2.next) {
|
|
75
|
+
case 0:
|
|
76
|
+
_render2 = (0, _react.render)( /*#__PURE__*/(0, _jsxRuntime.jsx)(_mdLabel["default"], {
|
|
77
|
+
expression: "This is an [internal link](/docs 'with a tooltip')"
|
|
78
|
+
})), container = _render2.container;
|
|
79
|
+
link = _react.screen.getByText('internal link'); // Get the link element by its text content
|
|
80
|
+
// Simulate hover event
|
|
81
|
+
_context2.next = 4;
|
|
82
|
+
return _userEvent["default"].hover(link);
|
|
83
|
+
case 4:
|
|
84
|
+
tooltip = null;
|
|
85
|
+
_context2.next = 7;
|
|
86
|
+
return (0, _react.waitFor)(function () {
|
|
87
|
+
tooltip = _react.screen.getByRole('tooltip');
|
|
88
|
+
});
|
|
89
|
+
case 7:
|
|
90
|
+
(0, _vitest.expect)(tooltip).toBeInTheDocument();
|
|
91
|
+
(0, _vitest.expect)(container).toMatchInlineSnapshot("\n\t\t\t<div>\n\t\t\t This is an \n\t\t\t <a\n\t\t\t class=\"link-md\"\n\t\t\t data-tooltip-id=\"tooltip-:r3:\"\n\t\t\t href=\"/docs\"\n\t\t\t id=\":r3:\"\n\t\t\t >\n\t\t\t internal link\n\t\t\t </a>\n\t\t\t <div\n\t\t\t class=\"react-tooltip core-styles-module_tooltip__3vRRp styles-module_tooltip__mnnfp styles-module_dark__xNqje tooltip-content react-tooltip__place-top core-styles-module_show__Nt9eE react-tooltip__show\"\n\t\t\t id=\"tooltip-:r3:\"\n\t\t\t role=\"tooltip\"\n\t\t\t style=\"left: 5px; top: -10px;\"\n\t\t\t >\n\t\t\t with a tooltip\n\t\t\t <div\n\t\t\t class=\"react-tooltip-arrow core-styles-module_arrow__cvMwQ styles-module_arrow__K0L3T\"\n\t\t\t style=\"left: -1px; bottom: -4px;\"\n\t\t\t />\n\t\t\t </div>\n\t\t\t</div>\n\t\t");
|
|
92
|
+
case 9:
|
|
93
|
+
case "end":
|
|
94
|
+
return _context2.stop();
|
|
95
|
+
}
|
|
96
|
+
}, _callee2);
|
|
97
|
+
})));
|
|
27
98
|
});
|
|
@@ -0,0 +1,29 @@
|
|
|
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["default"] = void 0;
|
|
8
|
+
var _createCustomizableField = _interopRequireDefault(require("../../create-customizable-field"));
|
|
9
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
10
|
+
var _excluded = ["to", "children"];
|
|
11
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
12
|
+
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; }
|
|
13
|
+
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; }
|
|
14
|
+
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; }
|
|
15
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
16
|
+
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); }
|
|
17
|
+
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
18
|
+
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
19
|
+
var RouterLink = function RouterLink(props) {
|
|
20
|
+
var to = props.to,
|
|
21
|
+
children = props.children,
|
|
22
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
23
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("a", _objectSpread(_objectSpread({
|
|
24
|
+
href: to
|
|
25
|
+
}, rest), {}, {
|
|
26
|
+
children: children
|
|
27
|
+
}));
|
|
28
|
+
};
|
|
29
|
+
var _default = exports["default"] = (0, _createCustomizableField["default"])(RouterLink, 'RouterLink');
|
|
@@ -7,7 +7,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
7
7
|
exports["default"] = void 0;
|
|
8
8
|
var _propTypes = _interopRequireDefault(require("prop-types"));
|
|
9
9
|
var _react = _interopRequireWildcard(require("react"));
|
|
10
|
-
var _reactTooltip =
|
|
10
|
+
var _reactTooltip = require("react-tooltip");
|
|
11
11
|
var _img = require("./img");
|
|
12
12
|
require("./variable-status.scss");
|
|
13
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
@@ -71,7 +71,7 @@ var VariableStatus = function VariableStatus(_ref) {
|
|
|
71
71
|
alt: "img-tooltip",
|
|
72
72
|
src: (_img$imgName = img[imgName]) !== null && _img$imgName !== void 0 ? _img$imgName : ''
|
|
73
73
|
})
|
|
74
|
-
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactTooltip
|
|
74
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactTooltip.Tooltip, {
|
|
75
75
|
id: "".concat(id, "-management-tooltip"),
|
|
76
76
|
className: "tooltip-text",
|
|
77
77
|
place: "left"
|
|
@@ -125,7 +125,7 @@
|
|
|
125
125
|
position: relative;
|
|
126
126
|
}
|
|
127
127
|
|
|
128
|
-
.link-md
|
|
128
|
+
.link-md {
|
|
129
129
|
border-bottom: dashed 0.1em var(--color-primary-dark);
|
|
130
130
|
&:hover {
|
|
131
131
|
cursor: help;
|
|
@@ -133,4 +133,22 @@
|
|
|
133
133
|
background-color: var(--color-primary-dark);
|
|
134
134
|
}
|
|
135
135
|
}
|
|
136
|
+
|
|
137
|
+
.tooltip-content {
|
|
138
|
+
min-width: 15em;
|
|
139
|
+
max-width: 25em;
|
|
140
|
+
background: var(--color-primary-dark);
|
|
141
|
+
color: var(--color-primary-contrast-text);
|
|
142
|
+
padding: 0.5em;
|
|
143
|
+
border-radius: 6px;
|
|
144
|
+
font-size: 1em;
|
|
145
|
+
&.place-bottom {
|
|
146
|
+
&::before {
|
|
147
|
+
border-bottom: 10px solid var(--color-primary-dark);
|
|
148
|
+
}
|
|
149
|
+
&::after {
|
|
150
|
+
content: none;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
136
154
|
}
|
|
@@ -16,7 +16,7 @@ function useAutoFocus(wrapperRef, key) {
|
|
|
16
16
|
}
|
|
17
17
|
|
|
18
18
|
// First look for invalid fields, then all fields
|
|
19
|
-
var firstFocusableElement = (_ref = (_wrapperRef$current = wrapperRef.current) === null || _wrapperRef$current === void 0 ? void 0 : _wrapperRef$current.querySelector('button[aria-invalid], [href][aria-invalid], input[aria-invalid], select[aria-invalid], textarea[aria-invalid], [tabindex][aria-invalid]:not([tabindex="-1"])')) !== null && _ref !== void 0 ? _ref : (_wrapperRef$current2 = wrapperRef.current) === null || _wrapperRef$current2 === void 0 ? void 0 : _wrapperRef$current2.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
|
|
19
|
+
var firstFocusableElement = (_ref = (_wrapperRef$current = wrapperRef.current) === null || _wrapperRef$current === void 0 ? void 0 : _wrapperRef$current.querySelector('button[aria-invalid="true"], [href][aria-invalid="true"], input[aria-invalid="true"], select[aria-invalid="true"], textarea[aria-invalid="true"], [tabindex][aria-invalid="true"]:not([tabindex="-1"])')) !== null && _ref !== void 0 ? _ref : (_wrapperRef$current2 = wrapperRef.current) === null || _wrapperRef$current2 === void 0 ? void 0 : _wrapperRef$current2.querySelector('button, [href], input, select, textarea, [tabindex]:not([tabindex="-1"])');
|
|
20
20
|
|
|
21
21
|
// The first element can be focusable
|
|
22
22
|
if (firstFocusableElement) {
|
|
@@ -73,6 +73,7 @@ declare class LunaticVariable {
|
|
|
73
73
|
* Set the value and returns true if the variable is touched
|
|
74
74
|
*/
|
|
75
75
|
setValue(value: unknown, iteration?: IterationLevel): boolean;
|
|
76
|
+
private setValueForArray;
|
|
76
77
|
private getSavedValue;
|
|
77
78
|
private getDependencies;
|
|
78
79
|
private getDependenciesValues;
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { FilledLunaticComponentProps } from '../commons/fill-components/fill-components';
|
|
2
|
+
import type { LunaticState } from '../type';
|
|
3
|
+
/**
|
|
4
|
+
* Check if a page has one response (value is filled for at least one field)
|
|
5
|
+
*/
|
|
6
|
+
export declare function usePageHasResponse(components: FilledLunaticComponentProps[], executeExpression: LunaticState['executeExpression']): () => boolean;
|
|
@@ -567,5 +567,6 @@ declare function useLunatic(source: LunaticSource, data: LunaticData | undefined
|
|
|
567
567
|
loopVariables: string[];
|
|
568
568
|
getChangedData: (reset?: boolean) => LunaticData;
|
|
569
569
|
resetChangedData: () => void;
|
|
570
|
+
hasPageResponse: () => boolean;
|
|
570
571
|
};
|
|
571
572
|
export default useLunatic;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = exports.Default = void 0;
|
|
7
|
+
var _react = _interopRequireDefault(require("react"));
|
|
8
|
+
var _orchestrator = _interopRequireDefault(require("../utils/orchestrator"));
|
|
9
|
+
var _defaultArgTypes = _interopRequireDefault(require("../utils/default-arg-types"));
|
|
10
|
+
var _source = _interopRequireDefault(require("./source.json"));
|
|
11
|
+
var _jsxRuntime = require("react/jsx-runtime");
|
|
12
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
13
|
+
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); }
|
|
14
|
+
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; }
|
|
15
|
+
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; }
|
|
16
|
+
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
|
+
function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
|
|
18
|
+
function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
|
|
19
|
+
var stories = {
|
|
20
|
+
title: 'Components/Markdown',
|
|
21
|
+
component: _orchestrator["default"],
|
|
22
|
+
argTypes: _defaultArgTypes["default"]
|
|
23
|
+
};
|
|
24
|
+
var _default = exports["default"] = stories;
|
|
25
|
+
var Template = function Template(args) {
|
|
26
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_orchestrator["default"], _objectSpread({}, args));
|
|
27
|
+
};
|
|
28
|
+
var Default = exports.Default = Template.bind({});
|
|
29
|
+
Default.args = {
|
|
30
|
+
id: 'markdown',
|
|
31
|
+
source: _source["default"]
|
|
32
|
+
};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
{
|
|
2
|
+
"maxPages": "1",
|
|
3
|
+
"components": [
|
|
4
|
+
{
|
|
5
|
+
"componentType": "Sequence",
|
|
6
|
+
"page": "1",
|
|
7
|
+
"conditionFilter": { "value": "true", "type": "VTL" },
|
|
8
|
+
"label": { "value": "\"Sequence example\"", "type": "VTL|MD" },
|
|
9
|
+
"declarations": [
|
|
10
|
+
{
|
|
11
|
+
"id": "kb9hi4j0-krnoclfe",
|
|
12
|
+
"declarationType": "INSTRUCTION",
|
|
13
|
+
"position": "BEFORE_QUESTION_TEXT",
|
|
14
|
+
"label": {
|
|
15
|
+
"value": "\"Déclaration Before with [internal link](/docs)\"",
|
|
16
|
+
"type": "VTL|MD"
|
|
17
|
+
}
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"id": "kb9hi4j0-krnoclfe",
|
|
21
|
+
"declarationType": "INSTRUCTION",
|
|
22
|
+
"position": "AFTER_QUESTION_TEXT",
|
|
23
|
+
"label": {
|
|
24
|
+
"value": "\"Déclaration AFTER with [tooltip link](https://google.com 'une infobule avec du texte très très long pour voir ce que cela donne Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.') \"",
|
|
25
|
+
"type": "VTL|MD"
|
|
26
|
+
}
|
|
27
|
+
},
|
|
28
|
+
{
|
|
29
|
+
"id": "kb9hi4j0-krnoclfe",
|
|
30
|
+
"declarationType": "HELP",
|
|
31
|
+
"position": "DETACHABLE",
|
|
32
|
+
"label": {
|
|
33
|
+
"value": "\"Declaration Detachable with [external link](https://inseefr.github.io/Lunatic/)\"",
|
|
34
|
+
"type": "VTL|MD"
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
]
|
|
40
|
+
}
|
|
@@ -42,6 +42,30 @@ function fetchFake() {
|
|
|
42
42
|
return r.json();
|
|
43
43
|
});
|
|
44
44
|
}
|
|
45
|
+
function fetchPCS2020() {
|
|
46
|
+
return fetch('/libelles-pcs-2020.json').then(function (r) {
|
|
47
|
+
return r.json();
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
var infoPCS2020 = {
|
|
51
|
+
name: 'libelle-pcs2020',
|
|
52
|
+
fields: [{
|
|
53
|
+
name: 'id',
|
|
54
|
+
rules: ['[\\w]+'],
|
|
55
|
+
language: 'French',
|
|
56
|
+
min: 2
|
|
57
|
+
}],
|
|
58
|
+
queryParser: {
|
|
59
|
+
type: 'tokenized',
|
|
60
|
+
params: {
|
|
61
|
+
language: 'French',
|
|
62
|
+
pattern: '[\\w]+'
|
|
63
|
+
}
|
|
64
|
+
},
|
|
65
|
+
meloto: true,
|
|
66
|
+
version: '1',
|
|
67
|
+
stopWords: ['a', 'au', 'dans', 'de', 'des', 'du', 'en', 'er', 'la', 'le', 'ou', 'sur', 'd', 'l', 'aux', 'dans', 'un', 'une', 'pour', 'avec', 'chez', 'par', 'les']
|
|
68
|
+
};
|
|
45
69
|
var infoFake = {
|
|
46
70
|
name: 'fake',
|
|
47
71
|
fields: [{
|
|
@@ -77,7 +101,7 @@ var infoNaf = {
|
|
|
77
101
|
}
|
|
78
102
|
},
|
|
79
103
|
version: '1',
|
|
80
|
-
meloto:
|
|
104
|
+
meloto: true
|
|
81
105
|
};
|
|
82
106
|
function loadOne(_x, _x2) {
|
|
83
107
|
return _loadOne.apply(this, arguments);
|
|
@@ -186,6 +210,17 @@ var Template = function Template(args) {
|
|
|
186
210
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
187
211
|
children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("ul", {
|
|
188
212
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsxs)("li", {
|
|
213
|
+
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
214
|
+
type: "button",
|
|
215
|
+
value: "load PCS2020",
|
|
216
|
+
onClick: function onClick() {
|
|
217
|
+
return loadOne(infoPCS2020, fetchPCS2020);
|
|
218
|
+
}
|
|
219
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsx)(Search, {
|
|
220
|
+
storeInfo: infoPCS2020,
|
|
221
|
+
defaultValue: "st"
|
|
222
|
+
})]
|
|
223
|
+
}), /*#__PURE__*/(0, _jsxRuntime.jsxs)("li", {
|
|
189
224
|
children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("input", {
|
|
190
225
|
type: "button",
|
|
191
226
|
value: "load NAF",
|