@inseefr/lunatic 2.7.4 → 2.7.6

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.
Files changed (102) hide show
  1. package/README.fr.md +1 -1
  2. package/README.md +6 -1
  3. package/lib/components/commons/components/md-label/link.js +39 -34
  4. package/lib/components/commons/components/md-label/md-label.js +2 -2
  5. package/lib/components/commons/components/md-label/md-label.spec.js +71 -0
  6. package/lib/components/commons/components/md-label/router-link.js +29 -0
  7. package/lib/components/commons/components/variable-status/variable-status.js +2 -2
  8. package/lib/components/index.scss +19 -1
  9. package/lib/components/loop/block-for-loop.js +2 -0
  10. package/lib/components/loop/constant.js +10 -0
  11. package/lib/components/loop/roster-for-loop/roster-for-loop.js +42 -20
  12. package/lib/components/lunatic-components.js +45 -7
  13. package/lib/components/table/lunatic-table.js +5 -1
  14. package/lib/hooks/use-auto-focus.js +1 -1
  15. package/lib/src/components/commons/components/md-label/router-link.d.ts +6 -0
  16. package/lib/src/components/datepicker/lunatic-datepicker.d.ts +1 -1
  17. package/lib/src/components/loop/constant.d.ts +4 -0
  18. package/lib/src/components/loop/roster-for-loop/roster-for-loop.d.ts +1 -0
  19. package/lib/src/components/lunatic-components.d.ts +12 -5
  20. package/lib/src/components/type.d.ts +4 -1
  21. package/lib/src/use-lunatic/commons/compile-controls.d.ts +4 -3
  22. package/lib/src/use-lunatic/commons/fill-components/fill-component-required.d.ts +75 -70
  23. package/lib/src/use-lunatic/commons/fill-components/fill-from-state.d.ts +55 -50
  24. package/lib/src/use-lunatic/commons/fill-components/fill-iterations.d.ts +31 -26
  25. package/lib/src/use-lunatic/commons/fill-components/fill-specific-expression.d.ts +680 -73
  26. package/lib/src/use-lunatic/commons/use-components-from-state.d.ts +1 -1
  27. package/lib/src/use-lunatic/commons/variables/lunatic-variables-store.d.ts +1 -0
  28. package/lib/src/use-lunatic/hooks/use-page-has-response.d.ts +6 -0
  29. package/lib/src/use-lunatic/reducer/commons/is-loop-component.d.ts +2 -2
  30. package/lib/src/use-lunatic/reducer/controls/check-base-control.d.ts +2 -0
  31. package/lib/src/use-lunatic/reducer/{resolve-component-controls/resolve-roundabout-control.d.ts → controls/check-roundabout-control.d.ts} +2 -2
  32. package/lib/src/use-lunatic/type-source.d.ts +16 -10
  33. package/lib/src/use-lunatic/use-lunatic.d.ts +12 -5
  34. package/lib/src/utils/suggester-workers/searching/meloto-order.d.ts +2 -1
  35. package/lib/stories/behaviour/controls/controls.stories.js +14 -7
  36. package/lib/stories/behaviour/controls/loop.json +130 -0
  37. package/lib/stories/behaviour/controls/{V2_ControlesNonNum_horsBoucle_PasPageFin.json → simple.json} +2 -2
  38. package/lib/stories/date-picker/source.json +22 -67
  39. package/lib/stories/declaration/source.json +14 -28
  40. package/lib/stories/dropdown/source.json +11 -28
  41. package/lib/stories/filter-description/source.json +3 -2
  42. package/lib/stories/input/input.stories.js +1 -8
  43. package/lib/stories/input/source.json +1 -63
  44. package/lib/stories/input-number/input-number.stories.js +2 -22
  45. package/lib/stories/input-number/source.json +4 -6
  46. package/lib/stories/loop/{block-for-loop.stories.js → loop.stories.js} +10 -8
  47. package/lib/stories/loop/roster-for-loop.stories.js +8 -2
  48. package/lib/stories/loop/source-bloc.json +10 -39
  49. package/lib/stories/loop/source-paginated.json +65 -78
  50. package/lib/stories/{loop/paginated-loop.stories.js → markdown/markdown.stories.js} +4 -4
  51. package/lib/stories/markdown/source.json +40 -0
  52. package/lib/stories/overview/overview.stories.js +1 -1
  53. package/lib/stories/pairwise/pairwise-links.stories.js +4 -4
  54. package/lib/stories/pairwise/{links.json → source.json} +2 -6
  55. package/lib/stories/question-context/question-context.stories.js +31 -0
  56. package/lib/stories/question-context/source.json +13 -0
  57. package/lib/stories/question-explication/source.json +1 -1
  58. package/lib/stories/{loop/not-paginated-loop.stories.js → question-information/question-information.stories.js} +5 -8
  59. package/lib/stories/question-information/source.json +14 -0
  60. package/lib/stories/roundabout/source.json +21 -31
  61. package/lib/stories/sequence/sequence.stories.js +7 -1
  62. package/lib/stories/sequence/source.json +17 -0
  63. package/lib/stories/suggester/simple.json +1 -1
  64. package/lib/stories/suggester/suggester-workers.stories.js +36 -1
  65. package/lib/stories/table/source-colspan.json +314 -0
  66. package/lib/stories/table/table.stories.js +7 -1
  67. package/lib/stories/textarea/source.json +6 -22
  68. package/lib/stories/utils/orchestrator.js +89 -49
  69. package/lib/stories/utils/orchestrator.scss +49 -0
  70. package/lib/stories/utils/referentiel.js +8 -4
  71. package/lib/use-lunatic/commons/compile-controls.js +135 -34
  72. package/lib/use-lunatic/commons/fill-components/fill-component-value.js +10 -0
  73. package/lib/use-lunatic/commons/fill-components/fill-specific-expression.js +4 -1
  74. package/lib/use-lunatic/commons/variables/behaviours/cleaning-behaviour.js +14 -9
  75. package/lib/use-lunatic/commons/variables/get-questionnaire-data.js +6 -1
  76. package/lib/use-lunatic/commons/variables/lunatic-variables-store.js +25 -7
  77. package/lib/use-lunatic/commons/variables/lunatic-variables-store.spec.js +39 -0
  78. package/lib/use-lunatic/hooks/use-page-has-response.js +104 -0
  79. package/lib/use-lunatic/reducer/{resolve-component-controls/resolve-simple-control.js → controls/check-base-control.js} +5 -7
  80. package/lib/use-lunatic/reducer/{resolve-component-controls/resolve-roundabout-control.js → controls/check-roundabout-control.js} +2 -3
  81. package/lib/use-lunatic/reducer/overview/overview-on-init.js +6 -4
  82. package/lib/use-lunatic/type-source.js +1 -0
  83. package/lib/use-lunatic/use-lunatic.js +3 -1
  84. package/lib/utils/env.js +1 -1
  85. package/lib/utils/suggester-workers/searching/meloto-order.js +6 -5
  86. package/package.json +2 -2
  87. package/workers-release/lunatic-search-worker-0.3.0.js +1 -1
  88. package/lib/src/use-lunatic/commons/get-errors-without-empty-value.d.ts +0 -6
  89. package/lib/src/use-lunatic/reducer/resolve-component-controls/index.d.ts +0 -1
  90. package/lib/src/use-lunatic/reducer/resolve-component-controls/resolve-component-control.d.ts +0 -6
  91. package/lib/src/use-lunatic/reducer/resolve-component-controls/resolve-simple-control.d.ts +0 -3
  92. package/lib/stories/Introduction.stories.mdx +0 -112
  93. package/lib/stories/behaviour/controls/V2_Controles_BouclesLiees_PasPageFin.json +0 -533
  94. package/lib/stories/input/source-with-question.json +0 -80
  95. package/lib/stories/input-number/source-euros.json +0 -37
  96. package/lib/stories/input-number/source-thansand.json +0 -34
  97. package/lib/stories/loop/source-not-paginated.json +0 -138
  98. package/lib/use-lunatic/commons/get-errors-without-empty-value.js +0 -24
  99. package/lib/use-lunatic/reducer/resolve-component-controls/index.js +0 -12
  100. package/lib/use-lunatic/reducer/resolve-component-controls/resolve-component-control.js +0 -38
  101. /package/lib/stories/behaviour/controls/{V2_ControlesNum_horsBoucle_PasPageFin.json → simple-numeric.json} +0 -0
  102. /package/lib/stories/pairwise/{links-componentset.json → source-componentset.json} +0 -0
package/README.fr.md CHANGED
@@ -13,7 +13,7 @@ Lunatic est une librairie front-end sous forme de hook react et de librairies de
13
13
  - [Storybook](https://inseefr.github.io/Lunatic/storybook), branche `main`
14
14
  - [Storybook v1](https://inseefr.github.io/Lunatic/storybook-v1), branche `v1-main`
15
15
  - [Storybook Beta](https://inseefr.github.io/Lunatic/storybook-beta), branche `develop`
16
- - [Documentation](https://inseefr.github.io/Lunatic/fr/)
16
+ - [Documentation](https://inseefr.github.io/Lunatic/)
17
17
 
18
18
  ## Sommaire
19
19
 
package/README.md CHANGED
@@ -13,7 +13,7 @@ Lunatic is a front-end library in the form of a React hook and component librari
13
13
  - [Storybook 2.7](https://inseefr.github.io/Lunatic/storybook-2.7), branch `2.7`
14
14
  - [Storybook 2.6](https://inseefr.github.io/Lunatic/storybook-2.6), branch `2.6`
15
15
  - [Storybook v1](https://inseefr.github.io/Lunatic/storybook-0.3.9), branch `v1-main`
16
- - [Documentation](https://inseefr.github.io/Lunatic/en/)
16
+ - [Documentation](https://inseefr.github.io/Lunatic/)
17
17
 
18
18
  ## Table of Contents
19
19
 
@@ -22,12 +22,17 @@ Lunatic is a front-end library in the form of a React hook and component librari
22
22
  - [Usage](#usage)
23
23
  - [The useLunatic Hook](#the-uselunatic-hook)
24
24
  - [Components](#components)
25
+ - [Workers](#workers)
26
+ - [General](#general)
27
+ - [How it works](#how-it-works)
25
28
  - [Customization](#customization)
26
29
  - [Internal Working](#internal-working)
27
30
  - [General Functioning](#general-functioning)
28
31
  - [Pages and Pager](#pages-and-pager)
29
32
  - [VTL Execution](#vtl-execution)
30
33
  - [Convention and Best Practices](#convention-and-best-practices)
34
+ - [Stable Branchs](#stable-branchs)
35
+ - [Commits and feature branches](#commits-and-feature-branches)
31
36
 
32
37
  ## Usage
33
38
 
@@ -4,49 +4,54 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
- var _reactTooltip = _interopRequireDefault(require("react-tooltip"));
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
- // TODO: reactivate
15
- var listener = function listener( /* link = true */
16
- ) {
17
- return function () {
18
- // if (isFunction(logFunction))
19
- // logFunction(
20
- // createObjectEvent(
21
- // link ? `link-${href}` : `tooltip-${title}`,
22
- // link ? LINK_CATEGORY : TOOLTIP_CATEGORY,
23
- // EVENT_CLICK
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: "_blank",
31
- rel: "noreferrer noopener",
32
- onClick: listener(),
33
- children: children
34
- });
35
- return /*#__PURE__*/(0, _jsxRuntime.jsxs)("span", {
36
- className: "link-md",
37
- onPointerUp: listener( /*false*/),
38
- children: [/*#__PURE__*/(0, _jsxRuntime.jsx)("span", {
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["default"], {
45
- id: "".concat(title, "-tooltip"),
46
+ })), title && /*#__PURE__*/(0, _jsxRuntime.jsx)(_reactTooltip.Tooltip, {
46
47
  className: "tooltip-content",
47
- place: "bottom",
48
- effect: "solid",
49
- globalEventOff: "click"
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 = _interopRequireDefault(require("react-tooltip"));
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["default"], {
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 .field-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
  }
@@ -12,6 +12,7 @@ var _commons = require("../commons");
12
12
  var _declarations = require("../declarations");
13
13
  var _lunaticComponents = require("../lunatic-components");
14
14
  var _loopButton = require("./loop-button");
15
+ var _constant = require("./constant");
15
16
  var _jsxRuntime = require("react/jsx-runtime");
16
17
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
17
18
  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; }
@@ -80,6 +81,7 @@ var BlockForLoop = exports.BlockForLoop = (0, _commons.createCustomizableLunatic
80
81
  id: id
81
82
  }), (0, _array.times)(nbRows, function (n) {
82
83
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_lunaticComponents.LunaticComponents, {
84
+ blocklist: _constant.blockedInLoopComponents,
83
85
  components: getComponents(n),
84
86
  componentProps: function componentProps(c) {
85
87
  return _objectSpread(_objectSpread(_objectSpread({}, props), c), {}, {
@@ -0,0 +1,10 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.blockedInLoopComponents = void 0;
7
+ /**
8
+ * List of components blocked in non-paginated loop
9
+ */
10
+ var blockedInLoopComponents = exports.blockedInLoopComponents = ['RosterForLoop', 'Loop', 'PairwiseLinks', 'Roundabout', 'CheckboxGroup'];
@@ -6,6 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.RosterForLoop = void 0;
8
8
  var _react = require("react");
9
+ require("./roster.scss");
9
10
  var _declarations = require("../../declarations");
10
11
  var _commons = require("../../commons");
11
12
  var _loopButton = require("../loop-button");
@@ -14,6 +15,8 @@ var _htmlTable = require("../../commons/components/html-table");
14
15
  var _tableHeader = require("../../table/table-header");
15
16
  var _array = require("../../../utils/array");
16
17
  var _lunaticComponents = require("../../lunatic-components");
18
+ var _constant = require("../constant");
19
+ var _errors = require("../../commons/components/errors/errors");
17
20
  var _jsxRuntime = require("react/jsx-runtime");
18
21
  var _excluded = ["value", "lines", "handleChange", "declarations", "label", "headers", "iterations", "id", "getComponents"];
19
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -80,6 +83,7 @@ var RosterForLoop = exports.RosterForLoop = (0, _commons.createCustomizableLunat
80
83
  if (nbRows === 0) {
81
84
  return null;
82
85
  }
86
+ var cols = 0;
83
87
  return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
84
88
  children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_declarations.DeclarationsBeforeText, {
85
89
  declarations: declarations,
@@ -95,28 +99,46 @@ var RosterForLoop = exports.RosterForLoop = (0, _commons.createCustomizableLunat
95
99
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_htmlTable.Tbody, {
96
100
  id: id,
97
101
  children: (0, _array.times)(nbRows, function (n) {
98
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_htmlTable.Tr, {
99
- id: props.id,
100
- row: n,
101
- children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_lunaticComponents.LunaticComponents, {
102
- components: getComponents(n),
103
- componentProps: function componentProps(c) {
104
- return _objectSpread(_objectSpread(_objectSpread({}, otherProps), c), {}, {
105
- id: "".concat(c.id, "-").concat(n)
106
- });
107
- },
108
- wrapper: function wrapper(_ref3) {
109
- var id = _ref3.id,
110
- children = _ref3.children;
111
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_htmlTable.Td, {
112
- id: "".concat(id, "-").concat(n),
113
- children: children
114
- });
115
- }
116
- })
117
- }, n);
102
+ var components = getComponents(n);
103
+ var lineErrors = (0, _errors.getComponentErrors)(props.errors, "".concat(id, "-").concat(n));
104
+ var hasLineErrors = !!(lineErrors !== null && lineErrors !== void 0 && lineErrors.length);
105
+ cols = components.length;
106
+ return /*#__PURE__*/(0, _jsxRuntime.jsxs)(_jsxRuntime.Fragment, {
107
+ children: [/*#__PURE__*/(0, _jsxRuntime.jsx)(_htmlTable.Tr, {
108
+ id: props.id,
109
+ row: n,
110
+ className: hasLineErrors ? 'lunatic-row-has-error' : undefined,
111
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_lunaticComponents.LunaticComponents, {
112
+ blocklist: _constant.blockedInLoopComponents,
113
+ components: components,
114
+ componentProps: function componentProps(c) {
115
+ return _objectSpread(_objectSpread(_objectSpread({}, otherProps), c), {}, {
116
+ id: "".concat(c.id, "-").concat(n)
117
+ });
118
+ },
119
+ wrapper: function wrapper(_ref3) {
120
+ var id = _ref3.id,
121
+ children = _ref3.children;
122
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_htmlTable.Td, {
123
+ id: "".concat(id, "-").concat(n),
124
+ children: children
125
+ });
126
+ }
127
+ })
128
+ }, n), hasLineErrors && /*#__PURE__*/(0, _jsxRuntime.jsx)("tr", {
129
+ className: "lunatic-errors",
130
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)("td", {
131
+ colSpan: cols,
132
+ children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_commons.Errors, {
133
+ errors: lineErrors
134
+ })
135
+ })
136
+ })]
137
+ });
118
138
  })
119
139
  })]
140
+ }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_commons.Errors, {
141
+ errors: (0, _errors.getComponentErrors)(props.errors, id)
120
142
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_declarations.DeclarationsDetachable, {
121
143
  declarations: declarations,
122
144
  id: id
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.LunaticComponents = LunaticComponents;
7
+ exports.hasLabel = hasLabel;
7
8
  var _react = require("react");
8
9
  var lunaticComponents = _interopRequireWildcard(require("./index"));
9
10
  var _useAutoFocus = require("../hooks/use-auto-focus");
@@ -24,6 +25,7 @@ function LunaticComponents(_ref) {
24
25
  var components = _ref.components,
25
26
  autoFocusKey = _ref.autoFocusKey,
26
27
  componentProps = _ref.componentProps,
28
+ blocklist = _ref.blocklist,
27
29
  _ref$wrapper = _ref.wrapper,
28
30
  wrapper = _ref$wrapper === void 0 ? function (_ref2) {
29
31
  var children = _ref2.children;
@@ -40,21 +42,48 @@ function LunaticComponents(_ref) {
40
42
  ref: WrapperComponent === _react.Fragment ? undefined : wrapperRef,
41
43
  children: components.map(function (component, k) {
42
44
  if ((0, _component.hasComponentType)(component)) {
45
+ if (blocklist && blocklist.includes(component.componentType)) {
46
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Fragment, {
47
+ children: wrapper(_objectSpread({
48
+ children: /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
49
+ style: {
50
+ color: 'red'
51
+ },
52
+ children: ["Component \"", component.componentType, "\" is not allowed here"]
53
+ }),
54
+ index: k
55
+ }, component))
56
+ }, computeId(component, k));
57
+ }
43
58
  var _props = _objectSpread(_objectSpread({}, component), componentProps === null || componentProps === void 0 ? void 0 : componentProps(component));
44
59
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Fragment, {
45
60
  children: wrapper(_objectSpread({
46
61
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(LunaticComponent, _objectSpread({}, _props)),
47
62
  index: k
48
63
  }, _props))
49
- }, 'id' in component ? component.id : "index-".concat(k));
64
+ }, computeId(component, k));
50
65
  }
66
+
51
67
  // In some case (table for instance) we have static component that only have a label (no componentType)
52
- return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Fragment, {
53
- children: wrapper({
54
- children: component,
55
- index: k
56
- })
57
- }, "index-".concat(k));
68
+ if (hasLabel(component)) {
69
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Fragment, {
70
+ children: wrapper(_objectSpread(_objectSpread({}, component), {}, {
71
+ children: component.label,
72
+ index: k
73
+ }))
74
+ }, k);
75
+ }
76
+
77
+ // Component is a ReactNode
78
+ if ( /*#__PURE__*/(0, _react.isValidElement)(component)) {
79
+ return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Fragment, {
80
+ children: wrapper({
81
+ children: component,
82
+ index: k
83
+ })
84
+ }, k);
85
+ }
86
+ return null;
58
87
  })
59
88
  });
60
89
  }
@@ -62,4 +91,13 @@ function LunaticComponent(props) {
62
91
  // Component is too dynamic to be typed
63
92
  var Component = lunaticComponents[props.componentType];
64
93
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(Component, _objectSpread({}, props));
94
+ }
95
+ function computeId(component, fallback) {
96
+ if ('id' in component && typeof component.id === 'string') {
97
+ return component.id;
98
+ }
99
+ return fallback;
100
+ }
101
+ function hasLabel(component) {
102
+ return !!component && _typeof(component) === 'object' && 'label' in component && /*#__PURE__*/(0, _react.isValidElement)(component.label);
65
103
  }
@@ -48,11 +48,15 @@ function LunaticTable(props) {
48
48
  components: row,
49
49
  wrapper: function wrapper(_ref) {
50
50
  var children = _ref.children,
51
- index = _ref.index;
51
+ index = _ref.index,
52
+ colspan = _ref.colspan,
53
+ rowspan = _ref.rowspan;
52
54
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_htmlTable.Td, {
53
55
  id: id,
54
56
  row: rowIndex,
55
57
  index: index,
58
+ colSpan: colspan,
59
+ rowSpan: rowspan,
56
60
  children: children
57
61
  });
58
62
  }
@@ -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) {
@@ -0,0 +1,6 @@
1
+ import type { ComponentProps } from 'react';
2
+ type Props = Omit<ComponentProps<'a'>, 'href'> & {
3
+ to: string;
4
+ };
5
+ declare const _default: import("react").ComponentType<Props>;
6
+ export default _default;
@@ -1,6 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  declare const _default: import("react").ComponentType<import("../type").LunaticBaseProps<string | null> & {
3
- dateFormat: "YYYY-MM-DD" | "YYYY-MM" | "YYYY";
3
+ dateFormat: "YYYY-MM-DD" | "YYYY" | "YYYY-MM";
4
4
  min?: string | undefined;
5
5
  max?: string | undefined;
6
6
  response: {
@@ -0,0 +1,4 @@
1
+ /**
2
+ * List of components blocked in non-paginated loop
3
+ */
4
+ export declare const blockedInLoopComponents: string[];
@@ -1,4 +1,5 @@
1
1
  /// <reference types="react" />
2
+ import './roster.scss';
2
3
  /**
3
4
  * Loop displayed as a table
4
5
  */
@@ -1,15 +1,22 @@
1
1
  import { type PropsWithChildren, type ReactElement, type ReactNode } from 'react';
2
2
  import type { FilledLunaticComponentProps } from '../use-lunatic/commons/fill-components/fill-components';
3
- type Props<T extends Record<string, unknown>> = {
4
- components: (FilledLunaticComponentProps | ReactElement)[];
3
+ type Props<T extends FilledLunaticComponentProps, V = undefined> = {
4
+ components: (FilledLunaticComponentProps | ReactElement | {
5
+ label: string;
6
+ [key: string]: unknown;
7
+ })[];
5
8
  autoFocusKey?: string;
6
- componentProps?: (component: FilledLunaticComponentProps) => T;
7
- wrapper?: (props: PropsWithChildren<FilledLunaticComponentProps & T & {
9
+ componentProps?: (component: FilledLunaticComponentProps) => V;
10
+ blocklist?: string[];
11
+ wrapper?: (props: PropsWithChildren<FilledLunaticComponentProps & T & V & {
8
12
  index: number;
9
13
  }>) => ReactNode;
10
14
  };
11
15
  /**
12
16
  * Entry point for orchestrators, this component display the list of fields
13
17
  */
14
- export declare function LunaticComponents<T extends Record<string, unknown>>({ components, autoFocusKey, componentProps, wrapper, }: Props<T>): import("react/jsx-runtime").JSX.Element;
18
+ export declare function LunaticComponents<T extends FilledLunaticComponentProps, V = undefined>({ components, autoFocusKey, componentProps, blocklist, wrapper, }: Props<T, V>): import("react/jsx-runtime").JSX.Element;
19
+ export declare function hasLabel(component: unknown): component is {
20
+ label: ReactNode;
21
+ } & FilledLunaticComponentProps;
15
22
  export {};