@inseefr/lunatic 2.7.1 → 2.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/README.md +45 -11
  2. package/lib/components/checkbox/checkbox-boolean/html/checkbox-boolean.js +3 -3
  3. package/lib/components/checkbox/checkbox-boolean/lunatic-checkbox-boolean.js +2 -1
  4. package/lib/components/checkbox/checkbox-group/checkbox-group-content.js +0 -2
  5. package/lib/components/checkbox/checkbox-group/html/checkbox-group-content.js +4 -2
  6. package/lib/components/checkbox/checkbox-group/html/checkbox-group.js +3 -3
  7. package/lib/components/checkbox/checkbox-group/lunatic-checkbox-group.js +2 -2
  8. package/lib/components/checkbox/checkbox-one/lunatic-checkbox-one.js +2 -1
  9. package/lib/components/checkbox/commons/checkbox-option.js +3 -1
  10. package/lib/components/commons/components/combo-box/combo-box-container.js +1 -2
  11. package/lib/components/commons/components/combo-box/combo-box.js +2 -2
  12. package/lib/components/commons/components/combo-box/selection/LabelOrInput.js +3 -1
  13. package/lib/components/commons/components/combo-box/selection/input.js +3 -1
  14. package/lib/components/commons/components/combo-box/selection/selection.js +3 -1
  15. package/lib/components/commons/components/errors/errors.js +12 -10
  16. package/lib/components/commons/components/errors/errors.spec.js +6 -6
  17. package/lib/components/component-set/html/__snapshots__/component-set.spec.tsx.snap +2 -0
  18. package/lib/components/component-set/html/component-set.js +2 -2
  19. package/lib/components/datepicker/html/DatepickerField.js +47 -0
  20. package/lib/components/datepicker/html/__snapshots__/datepicker.spec.tsx.snap +209 -17
  21. package/lib/components/datepicker/html/datepicker.js +104 -21
  22. package/lib/components/datepicker/html/datepicker.scss +19 -1
  23. package/lib/components/datepicker/html/datepicker.spec.js +71 -23
  24. package/lib/components/datepicker/lunatic-datepicker.js +5 -2
  25. package/lib/components/dropdown/lunatic-dropdown.js +2 -1
  26. package/lib/components/duration/duration.js +6 -7
  27. package/lib/components/duration/duration.scss +6 -14
  28. package/lib/components/duration/durationInput.js +14 -8
  29. package/lib/components/duration/durationUtils.js +38 -8
  30. package/lib/components/input/html/__snapshots__/input.spec.tsx.snap +2 -0
  31. package/lib/components/input/html/input.js +3 -3
  32. package/lib/components/input/lunatic-input.js +2 -1
  33. package/lib/components/input-number/html/__snapshots__/input-number.spec.tsx.snap +2 -2
  34. package/lib/components/input-number/html/input-number-thousand.js +4 -17
  35. package/lib/components/input-number/html/input-number.js +3 -5
  36. package/lib/components/input-number/lunatic-input-number.js +2 -3
  37. package/lib/components/loop/roster-for-loop/__snapshots__/roster-for-loop.spec.tsx.snap +88 -0
  38. package/lib/components/loop/roster-for-loop/roster-for-loop.js +7 -3
  39. package/lib/components/loop/roster-for-loop/roster-for-loop.spec.js +46 -0
  40. package/lib/components/lunatic-components.js +2 -11
  41. package/lib/components/radio/html/radio-group-content.js +4 -2
  42. package/lib/components/radio/html/radio-group.js +3 -3
  43. package/lib/components/radio/html/radio-option.js +3 -1
  44. package/lib/components/radio/lunatic-radio-group.js +2 -1
  45. package/lib/components/suggester/find-best-label/find-best-label.js +5 -5
  46. package/lib/components/suggester/idb-suggester/check-store.js +6 -3
  47. package/lib/components/suggester/idb-suggester/idb-suggester.js +8 -7
  48. package/lib/components/suggester/idb-suggester/suggester-status.js +1 -4
  49. package/lib/components/suggester/lunatic-suggester.js +7 -4
  50. package/lib/components/suggester/searching/create-searching.js +19 -42
  51. package/lib/components/switch/html/switch.js +2 -2
  52. package/lib/components/switch/lunatic-switch.js +2 -1
  53. package/lib/components/table/lunatic-table.js +2 -2
  54. package/lib/components/textarea/html/__snapshots__/textarea.spec.tsx.snap +2 -0
  55. package/lib/components/textarea/html/textarea.js +6 -4
  56. package/lib/components/textarea/lunatic-textarea.js +6 -3
  57. package/lib/hooks/use-auto-focus.js +26 -0
  58. package/lib/src/components/checkbox/checkbox-boolean/html/checkbox-boolean.d.ts +1 -1
  59. package/lib/src/components/checkbox/checkbox-group/html/checkbox-group-content.d.ts +2 -1
  60. package/lib/src/components/checkbox/checkbox-group/html/checkbox-group.d.ts +1 -1
  61. package/lib/src/components/checkbox/commons/checkbox-option.d.ts +1 -0
  62. package/lib/src/components/commons/components/combo-box/combo-box-container.d.ts +2 -2
  63. package/lib/src/components/commons/components/combo-box/combo-box.d.ts +2 -2
  64. package/lib/src/components/commons/components/combo-box/selection/LabelOrInput.d.ts +1 -0
  65. package/lib/src/components/commons/components/combo-box/selection/input.d.ts +1 -0
  66. package/lib/src/components/commons/components/combo-box/selection/selection.d.ts +2 -1
  67. package/lib/src/components/commons/components/errors/errors.d.ts +6 -3
  68. package/lib/src/components/datepicker/html/DatepickerField.d.ts +12 -0
  69. package/lib/src/components/datepicker/html/datepicker.d.ts +4 -3
  70. package/lib/src/components/datepicker/lunatic-datepicker.d.ts +1 -0
  71. package/lib/src/components/dropdown/html/dropdown-writable/dropdown-writable.d.ts +1 -1
  72. package/lib/src/components/dropdown/html/dropdown.d.ts +3 -1
  73. package/lib/src/components/duration/durationInput.d.ts +6 -2
  74. package/lib/src/components/duration/durationUtils.d.ts +24 -7
  75. package/lib/src/components/input/html/input.d.ts +2 -2
  76. package/lib/src/components/input-number/html/input-number-thousand.d.ts +2 -2
  77. package/lib/src/components/input-number/html/input-number.d.ts +2 -3
  78. package/lib/src/components/radio/html/radio-group-content.d.ts +2 -1
  79. package/lib/src/components/radio/html/radio-group.d.ts +1 -1
  80. package/lib/src/components/radio/html/radio-option.d.ts +1 -0
  81. package/lib/src/components/suggester/find-best-label/find-best-label.d.ts +1 -1
  82. package/lib/src/components/suggester/html/suggester.d.ts +1 -1
  83. package/lib/src/components/suggester/idb-suggester/check-store.d.ts +5 -2
  84. package/lib/src/components/suggester/idb-suggester/idb-suggester.d.ts +5 -2
  85. package/lib/src/components/suggester/idb-suggester/suggester-status.d.ts +1 -4
  86. package/lib/src/components/suggester/lunatic-suggester.d.ts +1 -1
  87. package/lib/src/components/suggester/searching/create-searching.d.ts +1 -1
  88. package/lib/src/components/switch/html/switch.d.ts +1 -1
  89. package/lib/src/components/textarea/html/textarea.d.ts +3 -2
  90. package/lib/src/components/type.d.ts +5 -3
  91. package/lib/src/hooks/use-auto-focus.d.ts +6 -0
  92. package/lib/src/use-lunatic/actions.d.ts +2 -0
  93. package/lib/src/use-lunatic/commons/fill-components/fill-component-required.d.ts +383 -0
  94. package/lib/src/use-lunatic/commons/fill-components/fill-component-value.d.ts +1 -1
  95. package/lib/src/use-lunatic/commons/fill-components/fill-component-value.spec.d.ts +1 -0
  96. package/lib/src/use-lunatic/commons/fill-components/fill-from-state.d.ts +20 -0
  97. package/lib/src/use-lunatic/commons/variables/lunatic-variables-store.d.ts +4 -0
  98. package/lib/src/use-lunatic/reducer/overview/overview-on-init.d.ts +1 -0
  99. package/lib/src/use-lunatic/type.d.ts +1 -0
  100. package/lib/src/use-lunatic/use-lunatic.d.ts +8 -3
  101. package/lib/src/use-lunatic/use-suggesters.d.ts +2 -1
  102. package/lib/src/utils/suggester-workers/append-to-index/create-append-task.d.ts +2 -2
  103. package/lib/src/utils/suggester-workers/worker-path.d.ts +6 -0
  104. package/lib/stories/behaviour/cleaning/source.json +151 -0
  105. package/lib/stories/behaviour/cleaning/test.stories.js +82 -0
  106. package/lib/stories/{questionnaires-test → behaviour}/controls/controls.stories.js +5 -5
  107. package/lib/stories/{questionnaires-test → behaviour/others}/test.stories.js +7 -7
  108. package/lib/stories/{paste-questionnaire → behaviour/paste}/test.stories.js +3 -3
  109. package/lib/stories/{resizing-questionnaire → behaviour/resizing}/test.stories.js +3 -3
  110. package/lib/stories/date-picker/datepicker.stories.js +32 -29
  111. package/lib/stories/duration/duration.stories.js +4 -4
  112. package/lib/stories/duration/{source.json → mois.json} +1 -1
  113. package/lib/stories/duration/{source1.json → time.json} +1 -1
  114. package/lib/use-lunatic/commons/fill-components/fill-component-required.js +23 -0
  115. package/lib/use-lunatic/commons/fill-components/fill-component-value.js +1 -1
  116. package/lib/use-lunatic/commons/fill-components/fill-component-value.spec.js +67 -0
  117. package/lib/use-lunatic/commons/fill-components/fill-components.js +2 -1
  118. package/lib/use-lunatic/commons/fill-components/fill-from-state.js +2 -0
  119. package/lib/use-lunatic/commons/variables/lunatic-variables-store.js +15 -0
  120. package/lib/use-lunatic/commons/variables/lunatic-variables-store.spec.js +9 -1
  121. package/lib/use-lunatic/initial-state.js +2 -1
  122. package/lib/use-lunatic/reducer/reduce-on-init.js +4 -2
  123. package/lib/use-lunatic/use-lunatic.js +7 -3
  124. package/lib/use-lunatic/use-suggesters.js +54 -37
  125. package/lib/utils/env.js +9 -1
  126. package/lib/utils/suggester-workers/append-to-index/create-append-task.js +5 -4
  127. package/lib/utils/suggester-workers/create-worker.js +10 -1
  128. package/lib/utils/suggester-workers/worker-path.js +29 -0
  129. package/package.json +24 -11
  130. package/scripts/build/add-workers-to-public.js +44 -0
  131. package/scripts/build/workers-paths.js +45 -0
  132. package/workers-release/lunatic-append-worker-0.3.0.js +2 -0
  133. package/workers-release/lunatic-append-worker-0.3.0.js.LICENSE.txt +34 -0
  134. package/workers-release/lunatic-label-worker-0.3.0.js +2 -0
  135. package/workers-release/lunatic-label-worker-0.3.0.js.LICENSE.txt +13 -0
  136. package/workers-release/lunatic-search-worker-0.3.0.js +2 -0
  137. package/workers-release/lunatic-search-worker-0.3.0.js.LICENSE.txt +34 -0
  138. package/lib/components/datepicker/html/datepicker-container.js +0 -17
  139. package/lib/components/datepicker/html/datepicker-input.js +0 -35
  140. package/lib/env.d.js +0 -1
  141. package/lib/src/components/datepicker/html/datepicker-container.d.ts +0 -3
  142. package/lib/src/components/datepicker/html/datepicker-input.d.ts +0 -13
  143. package/lib/src/utils/get-component-value.d.ts +0 -5
  144. package/lib/src/utils/store-tools/worker-path.d.ts +0 -1
  145. package/lib/utils/get-component-value.js +0 -34
  146. package/lib/utils/get-component-value.test.js +0 -57
  147. package/lib/utils/store-tools/worker-path.js +0 -13
  148. package/lib/utils/suggester-workers/create-worker-ts.js +0 -54
  149. /package/lib/src/{utils/get-component-value.test.d.ts → components/loop/roster-for-loop/roster-for-loop.spec.d.ts} +0 -0
  150. /package/lib/src/utils/suggester-workers/{create-worker-ts.d.ts → create-worker.d.ts} +0 -0
  151. /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_ControlesNonNum_horsBoucle_PasPageFin.json +0 -0
  152. /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_ControlesNum_horsBoucle_PasPageFin.json +0 -0
  153. /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_Controles_BouclesLiees2_PasPageFin.json +0 -0
  154. /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_Controles_BouclesLiees_PasPageFin.json +0 -0
  155. /package/lib/stories/{questionnaires-test → behaviour}/controls/boucles-n.json +0 -0
  156. /package/lib/stories/{questionnaires-test → behaviour}/controls/controls-externes.json +0 -0
  157. /package/lib/stories/{questionnaires-test → behaviour}/controls/controls-externes.stories.js +0 -0
  158. /package/lib/stories/{questionnaires-test → behaviour/others}/V2_DeclarationsSimples.json +0 -0
  159. /package/lib/stories/{questionnaires-test → behaviour/others}/V2_MinMaxSum_Boucles.json +0 -0
  160. /package/lib/stories/{questionnaires-test → behaviour/others}/V2_QuestSimple_Boucles.json +0 -0
  161. /package/lib/stories/{questionnaires-test → behaviour/others}/V2_TCMRallyeGames.json +0 -0
  162. /package/lib/stories/{questionnaires-test → behaviour/others}/test-dylan.json +0 -0
  163. /package/lib/stories/{paste-questionnaire → behaviour/paste}/source.json +0 -0
  164. /package/lib/stories/{resizing-questionnaire → behaviour/resizing}/source.json +0 -0
@@ -32,17 +32,18 @@ function IDBSuggester(_ref) {
32
32
  description = _ref.description,
33
33
  getSuggesterStatus = _ref.getSuggesterStatus,
34
34
  errors = _ref.errors,
35
- readOnly = _ref.readOnly;
35
+ readOnly = _ref.readOnly,
36
+ workersBasePath = _ref.workersBasePath;
36
37
  var _useState = (0, _react.useState)(undefined),
37
38
  _useState2 = _slicedToArray(_useState, 2),
38
- store = _useState2[0],
39
- setStore = _useState2[1];
39
+ storeInfo = _useState2[0],
40
+ setStoreInfo = _useState2[1];
40
41
  var searching = (0, _react.useMemo)(function () {
41
- if (store) {
42
- return (0, _searching["default"])(storeName, idbVersion);
42
+ if (storeInfo) {
43
+ return (0, _searching["default"])(storeName, idbVersion, workersBasePath);
43
44
  }
44
45
  return undefined;
45
- }, [storeName, idbVersion, store]);
46
+ }, [storeInfo, storeName, idbVersion, workersBasePath]);
46
47
  return /*#__PURE__*/(0, _jsxRuntime.jsx)(_suggesterStatus.SuggesterStatus, {
47
48
  storeName: storeName,
48
49
  getSuggesterStatus: getSuggesterStatus,
@@ -51,7 +52,7 @@ function IDBSuggester(_ref) {
51
52
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_checkStore["default"], {
52
53
  storeName: storeName,
53
54
  version: parseInt(idbVersion, 10),
54
- setStore: setStore,
55
+ onInfo: setStoreInfo,
55
56
  children: /*#__PURE__*/(0, _jsxRuntime.jsx)(_suggester["default"], {
56
57
  id: id,
57
58
  className: className,
@@ -20,10 +20,7 @@ var STATUS = exports.STATUS = {
20
20
  error: 5
21
21
  };
22
22
  /**
23
- * Component witch check status of loading process.
24
- * it notifies users through SuggesterNotification, a customizable component.
25
- * @param {} param0
26
- * @returns
23
+ * Check the status of suggester status and shows a warning / error
27
24
  */
28
25
  function SuggesterStatus(_ref) {
29
26
  var children = _ref.children,
@@ -4,9 +4,10 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports["default"] = void 0;
7
- var _idbSuggester = require("./idb-suggester");
7
+ var _errors = require("../commons/components/errors/errors");
8
8
  var _lunaticComponentWithoutLabel = _interopRequireDefault(require("../commons/components/lunatic-component-without-label"));
9
9
  var _useOnHandleChange = _interopRequireDefault(require("../commons/use-on-handle-change"));
10
+ var _idbSuggester = require("./idb-suggester");
10
11
  var _jsxRuntime = require("react/jsx-runtime");
11
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
13
  function LunaticSuggester(_ref) {
@@ -30,7 +31,8 @@ function LunaticSuggester(_ref) {
30
31
  management = _ref.management,
31
32
  response = _ref.response,
32
33
  className = _ref.className,
33
- getSuggesterStatus = _ref.getSuggesterStatus;
34
+ getSuggesterStatus = _ref.getSuggesterStatus,
35
+ workersBasePath = _ref.workersBasePath;
34
36
  var onChange = (0, _useOnHandleChange["default"])({
35
37
  handleChange: handleChange,
36
38
  response: response,
@@ -55,11 +57,12 @@ function LunaticSuggester(_ref) {
55
57
  disabled: disabled,
56
58
  id: id,
57
59
  value: value,
58
- errors: errors,
60
+ errors: (0, _errors.getComponentErrors)(errors, id),
59
61
  label: label,
60
62
  getSuggesterStatus: getSuggesterStatus,
61
63
  className: className,
62
- readOnly: readOnly
64
+ readOnly: readOnly,
65
+ workersBasePath: workersBasePath
63
66
  })
64
67
  });
65
68
  }
@@ -7,59 +7,36 @@ Object.defineProperty(exports, "__esModule", {
7
7
  exports["default"] = void 0;
8
8
  exports.isWorkerCompatible = isWorkerCompatible;
9
9
  var _createWorker = require("../../../utils/suggester-workers/create-worker");
10
+ var _workerPath = require("../../../utils/suggester-workers/worker-path");
10
11
  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
12
  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
13
  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); }); }; } // @ts-ignore
13
- var WORKER_PATH =
14
- // @ts-ignore
15
- import.meta.env.LUNATIC_SEARCH_WORKER_PATH ||
16
- // @ts-ignore
17
- import.meta.env.REACT_APP_LUNATIC_SEARCH_WORKER_PATH;
18
14
  function isWorkerCompatible() {
19
15
  return !!window.Worker;
20
16
  }
21
- var searching = function searching(worker) {
22
- return function (search, name, version) {
23
- if (!WORKER_PATH) {
24
- throw new Error("Worker path is required for suggester's searches.");
25
- }
26
- if (isWorkerCompatible()) {
27
- return new Promise(function (resolve) {
28
- try {
29
- if (worker) {
30
- worker.terminate();
31
- }
32
- worker = (0, _createWorker.createWorker)(WORKER_PATH);
33
- worker.postMessage({
34
- search: search,
35
- name: name,
36
- version: version
37
- });
38
- worker.addEventListener('message', function (e) {
39
- var _worker;
40
- var data = e.data;
41
- resolve(data);
42
- (_worker = worker) === null || _worker === void 0 || _worker.terminate();
43
- worker = undefined;
44
- });
45
- } catch (e) {
46
- //TODO
47
- }
48
- });
49
- }
50
- // TODO
51
- return Promise.reject('No worker found');
52
- };
53
- };
54
- function createSearching(name, version) {
55
- var worker = undefined;
56
- var searching_ = searching(worker);
17
+ function getWorker(resolve, workersBasePath) {
18
+ var WORKER = (0, _createWorker.createWorker)((0, _workerPath.getWorkerPath)(_workerPath.WorkerEnum.SEARCH, workersBasePath));
19
+ WORKER.addEventListener('message', function (e) {
20
+ var data = e.data;
21
+ resolve(data);
22
+ WORKER === null || WORKER === void 0 || WORKER.terminate();
23
+ });
24
+ return WORKER;
25
+ }
26
+ function createSearching(name, version, workersBasePath) {
57
27
  return /*#__PURE__*/function () {
58
28
  var _ref = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee(search) {
59
29
  return _regeneratorRuntime().wrap(function _callee$(_context) {
60
30
  while (1) switch (_context.prev = _context.next) {
61
31
  case 0:
62
- return _context.abrupt("return", searching_(search, name, version));
32
+ return _context.abrupt("return", new Promise(function (resolve) {
33
+ var worker = getWorker(resolve, workersBasePath);
34
+ worker.postMessage({
35
+ search: search,
36
+ name: name,
37
+ version: version
38
+ });
39
+ }));
63
40
  case 1:
64
41
  case "end":
65
42
  return _context.stop();
@@ -45,6 +45,7 @@ function Switch(_ref) {
45
45
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
46
46
  role: "switch",
47
47
  "aria-checked": checked,
48
+ "aria-invalid": !!errors,
48
49
  tabIndex: 0,
49
50
  className: (0, _classnames["default"])('lunatic-switch-container', {
50
51
  disabled: disabled,
@@ -63,8 +64,7 @@ function Switch(_ref) {
63
64
  children: labelTrue
64
65
  })]
65
66
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_commons.Errors, {
66
- errors: errors,
67
- activeId: id
67
+ errors: errors
68
68
  })]
69
69
  });
70
70
  }
@@ -7,6 +7,7 @@ exports["default"] = void 0;
7
7
  var _switch = _interopRequireDefault(require("./html/switch"));
8
8
  var _lunaticComponentWithoutLabel = _interopRequireDefault(require("../commons/components/lunatic-component-without-label"));
9
9
  var _useOnHandleChange = _interopRequireDefault(require("../commons/use-on-handle-change"));
10
+ var _errors = require("../commons/components/errors/errors");
10
11
  var _jsxRuntime = require("react/jsx-runtime");
11
12
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
12
13
  var defaultLabel = {
@@ -50,7 +51,7 @@ function LunaticSwitch(_ref) {
50
51
  onClick: onClick,
51
52
  statusLabel: statusLabel,
52
53
  label: label,
53
- errors: errors
54
+ errors: (0, _errors.getComponentErrors)(errors, id)
54
55
  })
55
56
  });
56
57
  }
@@ -10,6 +10,7 @@ var _lunaticComponentWithLabel = _interopRequireDefault(require("../commons/comp
10
10
  var _commons = require("../commons");
11
11
  var _lunaticComponents = require("../lunatic-components");
12
12
  var _tableHeader = require("./table-header");
13
+ var _errors = require("../commons/components/errors/errors");
13
14
  var _jsxRuntime = require("react/jsx-runtime");
14
15
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
15
16
  function LunaticTable(props) {
@@ -60,8 +61,7 @@ function LunaticTable(props) {
60
61
  })
61
62
  })]
62
63
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_commons.Errors, {
63
- errors: errors,
64
- activeId: id
64
+ errors: (0, _errors.getComponentErrors)(errors, id)
65
65
  })]
66
66
  });
67
67
  }
@@ -6,6 +6,7 @@ exports[`Textarea > renders without crashing 1`] = `
6
6
  class="lunatic-textarea"
7
7
  >
8
8
  <textarea
9
+ aria-invalid="false"
9
10
  id="input"
10
11
  >
11
12
  input
@@ -20,6 +21,7 @@ exports[`Textarea > should handle readOnly 1`] = `
20
21
  class="lunatic-textarea"
21
22
  >
22
23
  <textarea
24
+ aria-invalid="false"
23
25
  id="textarea"
24
26
  readonly=""
25
27
  >
@@ -19,7 +19,8 @@ function Textarea(_ref) {
19
19
  label = _ref.label,
20
20
  description = _ref.description,
21
21
  errors = _ref.errors,
22
- readOnly = _ref.readOnly;
22
+ readOnly = _ref.readOnly,
23
+ required = _ref.required;
23
24
  var labelId = "label-".concat(id);
24
25
  var handleChange = (0, _react.useCallback)(function (e) {
25
26
  onChange(e.target.value);
@@ -32,6 +33,7 @@ function Textarea(_ref) {
32
33
  description: description,
33
34
  children: label
34
35
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)("textarea", {
36
+ required: required,
35
37
  id: id,
36
38
  rows: rows,
37
39
  maxLength: maxLength,
@@ -39,10 +41,10 @@ function Textarea(_ref) {
39
41
  onChange: handleChange,
40
42
  value: checkValue(value),
41
43
  placeholder: placeholder,
42
- readOnly: readOnly
44
+ readOnly: readOnly,
45
+ "aria-invalid": !!errors
43
46
  }), /*#__PURE__*/(0, _jsxRuntime.jsx)(_commons.Errors, {
44
- errors: errors,
45
- activeId: id
47
+ errors: errors
46
48
  })]
47
49
  });
48
50
  }
@@ -8,6 +8,7 @@ var _propTypes = _interopRequireDefault(require("prop-types"));
8
8
  var _lunaticComponentWithoutLabel = _interopRequireDefault(require("../commons/components/lunatic-component-without-label"));
9
9
  var _useOnHandleChange = _interopRequireDefault(require("../commons/use-on-handle-change"));
10
10
  var _textarea = _interopRequireDefault(require("./html/textarea"));
11
+ var _errors = require("../commons/components/errors/errors");
11
12
  var _jsxRuntime = require("react/jsx-runtime");
12
13
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
13
14
  var LunaticTextarea = function LunaticTextarea(props) {
@@ -27,7 +28,8 @@ var LunaticTextarea = function LunaticTextarea(props) {
27
28
  missing = props.missing,
28
29
  missingResponse = props.missingResponse,
29
30
  management = props.management,
30
- readOnly = props.readOnly;
31
+ readOnly = props.readOnly,
32
+ required = props.required;
31
33
  var onChange = (0, _useOnHandleChange["default"])({
32
34
  handleChange: handleChange,
33
35
  response: response,
@@ -52,8 +54,9 @@ var LunaticTextarea = function LunaticTextarea(props) {
52
54
  value: value,
53
55
  placeholder: placeHolder,
54
56
  label: label,
55
- errors: errors,
56
- readOnly: readOnly
57
+ errors: (0, _errors.getComponentErrors)(errors, id),
58
+ readOnly: readOnly,
59
+ required: required
57
60
  })
58
61
  });
59
62
  };
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.useAutoFocus = useAutoFocus;
7
+ var _react = require("react");
8
+ /**
9
+ * Focus the first focusable element in the wrapper when the "key" changes and is defined
10
+ */
11
+ function useAutoFocus(wrapperRef, key) {
12
+ (0, _react.useEffect)(function () {
13
+ var _ref, _wrapperRef$current, _wrapperRef$current2;
14
+ if (!key || !wrapperRef.current) {
15
+ return;
16
+ }
17
+
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"])');
20
+
21
+ // The first element can be focusable
22
+ if (firstFocusableElement) {
23
+ return firstFocusableElement.focus();
24
+ }
25
+ }, [key, wrapperRef]);
26
+ }
@@ -7,7 +7,7 @@ type Props = {
7
7
  onClick?: (b: boolean) => void;
8
8
  label?: ReactNode;
9
9
  description?: ReactNode;
10
- errors?: Record<string, LunaticError[]>;
10
+ errors?: LunaticError[];
11
11
  };
12
12
  declare const _default: import("react").ComponentType<Props>;
13
13
  export default _default;
@@ -3,6 +3,7 @@ type Props = {
3
3
  options: CheckboxGroupOption[];
4
4
  id: string;
5
5
  shortcut?: boolean;
6
+ invalid?: boolean;
6
7
  };
7
- declare function CheckboxGroupContent({ options, id, shortcut }: Props): import("react/jsx-runtime").JSX.Element;
8
+ declare function CheckboxGroupContent({ options, id, shortcut, invalid }: Props): import("react/jsx-runtime").JSX.Element;
8
9
  export default CheckboxGroupContent;
@@ -4,7 +4,7 @@ import type { LunaticError } from '../../../../use-lunatic/type';
4
4
  import { type CheckboxGroupOption } from '../lunatic-checkbox-group';
5
5
  type Props = {
6
6
  options: CheckboxGroupOption[];
7
- errors?: Record<string, LunaticError[]>;
7
+ errors?: LunaticError[];
8
8
  id: string;
9
9
  label?: ReactNode;
10
10
  description?: ReactNode;
@@ -10,6 +10,7 @@ export type CheckboxOptionProps = {
10
10
  description?: LunaticBaseProps['description'];
11
11
  codeModality?: string;
12
12
  shortcut?: boolean;
13
+ invalid?: boolean;
13
14
  };
14
15
  declare const _default: import("react").ComponentType<CheckboxOptionProps>;
15
16
  export default _default;
@@ -1,11 +1,11 @@
1
1
  import type { PropsWithChildren } from 'react';
2
- import type { LunaticBaseProps } from '../../../type';
2
+ import type { LunaticError } from '../../../../use-lunatic/type';
3
3
  type Props = PropsWithChildren<{
4
4
  classNamePrefix?: string;
5
5
  className?: string;
6
6
  id?: string;
7
7
  classStyle?: string;
8
- errors?: LunaticBaseProps['errors'];
8
+ errors?: LunaticError[];
9
9
  }>;
10
10
  declare const _default: import("react").ComponentType<Props>;
11
11
  export default _default;
@@ -1,9 +1,9 @@
1
1
  import { type ReactNode } from 'react';
2
- import type { LunaticBaseProps } from '../../../type';
3
2
  import './combo-box.scss';
4
3
  import type { ComboBoxOptionType } from './combo-box.type';
5
4
  import { type PanelProps } from './panel/panel';
6
5
  import { type SelectionProps } from './selection/selection';
6
+ import type { LunaticError } from '../../../../use-lunatic/type';
7
7
  type Props = SelectionProps & PanelProps & {
8
8
  className?: string;
9
9
  classNamePrefix?: string;
@@ -13,7 +13,7 @@ type Props = SelectionProps & PanelProps & {
13
13
  getOptionValue?: (o: ComboBoxOptionType) => string;
14
14
  label?: ReactNode;
15
15
  description?: ReactNode;
16
- errors?: LunaticBaseProps['errors'];
16
+ errors?: LunaticError[];
17
17
  onChange?: (s: string | null) => void;
18
18
  onSelect: (s: string | null) => void;
19
19
  options: ComboBoxOptionType[];
@@ -4,6 +4,7 @@ type LabelOrInputTypeProps = LabelSelectionProps & InputProps & {
4
4
  editable?: boolean;
5
5
  expanded?: boolean;
6
6
  readOnly?: boolean;
7
+ invalid?: boolean;
7
8
  };
8
9
  /**
9
10
  * Display the input or the label of the selection based on the state of the Suggester.
@@ -5,6 +5,7 @@ export type InputProps = {
5
5
  value?: string;
6
6
  labelledBy?: string;
7
7
  focused?: boolean;
8
+ invalid?: boolean;
8
9
  } & HTMLAttributes<HTMLInputElement>;
9
10
  declare const _default: React.ComponentType<Record<string, unknown>>;
10
11
  export default _default;
@@ -8,5 +8,6 @@ export type SelectionProps = {
8
8
  id?: string;
9
9
  classNamePrefix?: string;
10
10
  readOnly?: boolean;
11
+ invalid?: boolean;
11
12
  } & LabelSelectionProps;
12
- export declare function Selection({ labelRenderer, placeholder, search, expanded, disabled, readOnly, focused, onChange, selectedIndex, options, editable, labelId, id, classNamePrefix, }: SelectionProps): import("react/jsx-runtime").JSX.Element;
13
+ export declare function Selection({ labelRenderer, placeholder, search, expanded, disabled, readOnly, focused, onChange, selectedIndex, options, editable, labelId, id, classNamePrefix, invalid, }: SelectionProps): import("react/jsx-runtime").JSX.Element;
@@ -1,8 +1,11 @@
1
1
  import './errors.scss';
2
2
  import type { LunaticError } from '../../../../use-lunatic/type';
3
3
  type Props = {
4
- errors?: Record<string, LunaticError[]>;
5
- activeId?: string;
4
+ errors?: LunaticError[];
6
5
  };
7
- declare function Errors({ errors, activeId }: Props): import("react/jsx-runtime").JSX.Element | null;
6
+ /**
7
+ * Display a list of error as simple red text
8
+ */
9
+ declare function Errors({ errors }: Props): import("react/jsx-runtime").JSX.Element | null;
10
+ export declare function getComponentErrors(errors?: Record<string, LunaticError[]>, componentId?: string): LunaticError[] | undefined;
8
11
  export default Errors;
@@ -0,0 +1,12 @@
1
+ type Props = {
2
+ id: string;
3
+ label: string;
4
+ description: string;
5
+ max?: number;
6
+ onChange: (value: number) => void;
7
+ value?: number;
8
+ readOnly?: boolean;
9
+ disabled?: boolean;
10
+ };
11
+ export declare function DatepickerField({ label, id, description, onChange, value, max, readOnly, disabled, }: Props): import("react/jsx-runtime").JSX.Element;
12
+ export {};
@@ -1,17 +1,18 @@
1
1
  import { type ReactNode } from 'react';
2
- import './datepicker.scss';
3
2
  import type { LunaticError } from '../../../use-lunatic/type';
3
+ import './datepicker.scss';
4
4
  type Props = {
5
5
  label?: ReactNode;
6
6
  description?: ReactNode;
7
- errors?: Record<string, LunaticError[]>;
7
+ errors?: LunaticError[];
8
8
  disabled?: boolean;
9
9
  readOnly?: boolean;
10
10
  min?: string;
11
11
  max?: string;
12
12
  id?: string;
13
13
  value?: string;
14
- onChange: (s: string) => void;
14
+ onChange: (s: string | null) => void;
15
+ format?: string;
15
16
  };
16
17
  declare const _default: import("react").ComponentType<Props>;
17
18
  export default _default;
@@ -1,5 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  declare const _default: import("react").ComponentType<import("../type").LunaticBaseProps<string | null> & {
3
+ format: "YYYY-MM-DD" | "YYYY-MM" | "YYYY";
3
4
  min?: string | undefined;
4
5
  max?: string | undefined;
5
6
  response: {
@@ -9,7 +9,7 @@ type Props = {
9
9
  className?: string;
10
10
  value: string | null;
11
11
  label?: ReactNode;
12
- errors?: Record<string, LunaticError[]>;
12
+ errors?: LunaticError[];
13
13
  description?: ReactNode;
14
14
  readOnly?: boolean;
15
15
  };
@@ -1,10 +1,12 @@
1
1
  /// <reference types="react" />
2
2
  import './dropdown.scss';
3
3
  import type { LunaticComponentProps } from '../../type';
4
+ import type { LunaticError } from '../../../use-lunatic/type';
4
5
  export type DropdownProps = {
5
6
  onSelect: (v: string | null) => void;
6
7
  className?: string;
7
8
  readOnly?: boolean;
8
- } & Pick<LunaticComponentProps<'Dropdown'>, 'id' | 'disabled' | 'options' | 'writable' | 'value' | 'description' | 'label' | 'errors'>;
9
+ errors?: LunaticError[];
10
+ } & Pick<LunaticComponentProps<'Dropdown'>, 'id' | 'disabled' | 'options' | 'writable' | 'value' | 'description' | 'label'>;
9
11
  declare const _default: import("react").ComponentType<DropdownProps>;
10
12
  export default _default;
@@ -1,7 +1,11 @@
1
+ import { type ReactNode } from 'react';
1
2
  import { type Formats } from './durationUtils';
2
- declare const DurationInput: ({ value, format, onChange, }: {
3
+ type Props = {
4
+ label?: ReactNode;
5
+ id?: string;
3
6
  value: string | null;
4
7
  format: Formats;
5
8
  onChange: (s: string | null) => void;
6
- }) => import("react/jsx-runtime").JSX.Element;
9
+ };
10
+ declare const DurationInput: ({ value, format, onChange, label }: Props) => import("react/jsx-runtime").JSX.Element;
7
11
  export default DurationInput;
@@ -7,19 +7,35 @@ export type DurationValue = {
7
7
  export type Formats = 'PTnHnM' | 'PnYnM';
8
8
  export declare const propsByUnit: {
9
9
  hours: {
10
- min: string;
11
- max: string;
10
+ min: number;
11
+ max: number;
12
+ size: number;
13
+ style: {
14
+ width: string;
15
+ };
12
16
  };
13
17
  minutes: {
14
- min: string;
15
- max: string;
18
+ min: number;
19
+ max: number;
20
+ size: number;
21
+ style: {
22
+ width: string;
23
+ };
16
24
  };
17
25
  months: {
18
- min: string;
19
- max: string;
26
+ min: number;
27
+ max: number;
28
+ size: number;
29
+ style: {
30
+ width: string;
31
+ };
20
32
  };
21
33
  years: {
22
- min: string;
34
+ min: number;
35
+ size: number;
36
+ style: {
37
+ width: string;
38
+ };
23
39
  };
24
40
  };
25
41
  export declare const labelByUnit: {
@@ -28,3 +44,4 @@ export declare const labelByUnit: {
28
44
  months: string;
29
45
  years: string;
30
46
  };
47
+ export declare function clampDuration(value: number | null, unit: keyof typeof propsByUnit): number | null;
@@ -1,11 +1,11 @@
1
1
  import { type ReactNode } from 'react';
2
2
  import './input.scss';
3
- import type { LunaticBaseProps } from '../../type';
3
+ import type { LunaticError } from '../../../use-lunatic/type';
4
4
  type Props = {
5
5
  label?: ReactNode;
6
6
  onChange: (v: string) => void;
7
7
  description?: string;
8
- errors: LunaticBaseProps['errors'];
8
+ errors?: LunaticError[];
9
9
  value?: string | null;
10
10
  disabled?: boolean;
11
11
  readOnly?: boolean;
@@ -6,9 +6,9 @@ type Props = {
6
6
  readOnly?: boolean;
7
7
  required?: boolean;
8
8
  labelId?: string;
9
- min?: number;
10
9
  max?: number;
11
10
  decimals?: number;
11
+ invalid?: boolean;
12
12
  };
13
- declare const InputNumberThousand: ({ id, onChange, value, disabled, readOnly, required, labelId, min, max, decimals, }: Props) => import("react/jsx-runtime").JSX.Element;
13
+ declare const InputNumberThousand: ({ id, onChange, value, disabled, readOnly, required, labelId, max, decimals, invalid, }: Props) => import("react/jsx-runtime").JSX.Element;
14
14
  export default InputNumberThousand;