@inseefr/lunatic 2.7.1 → 2.7.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -11
- package/lib/components/checkbox/checkbox-boolean/html/checkbox-boolean.js +3 -3
- package/lib/components/checkbox/checkbox-boolean/lunatic-checkbox-boolean.js +2 -1
- package/lib/components/checkbox/checkbox-group/checkbox-group-content.js +0 -2
- package/lib/components/checkbox/checkbox-group/html/checkbox-group-content.js +4 -2
- package/lib/components/checkbox/checkbox-group/html/checkbox-group.js +3 -3
- package/lib/components/checkbox/checkbox-group/lunatic-checkbox-group.js +2 -2
- package/lib/components/checkbox/checkbox-one/lunatic-checkbox-one.js +2 -1
- package/lib/components/checkbox/commons/checkbox-option.js +3 -1
- package/lib/components/commons/components/combo-box/combo-box-container.js +1 -2
- package/lib/components/commons/components/combo-box/combo-box.js +2 -2
- package/lib/components/commons/components/combo-box/selection/LabelOrInput.js +3 -1
- package/lib/components/commons/components/combo-box/selection/input.js +3 -1
- package/lib/components/commons/components/combo-box/selection/selection.js +3 -1
- package/lib/components/commons/components/errors/errors.js +12 -10
- package/lib/components/commons/components/errors/errors.spec.js +6 -6
- package/lib/components/component-set/html/__snapshots__/component-set.spec.tsx.snap +2 -0
- package/lib/components/component-set/html/component-set.js +2 -2
- package/lib/components/datepicker/html/DatepickerField.js +47 -0
- package/lib/components/datepicker/html/__snapshots__/datepicker.spec.tsx.snap +209 -17
- package/lib/components/datepicker/html/datepicker.js +104 -21
- package/lib/components/datepicker/html/datepicker.scss +19 -1
- package/lib/components/datepicker/html/datepicker.spec.js +71 -23
- package/lib/components/datepicker/lunatic-datepicker.js +5 -2
- package/lib/components/dropdown/lunatic-dropdown.js +2 -1
- package/lib/components/duration/duration.js +6 -7
- package/lib/components/duration/duration.scss +6 -14
- package/lib/components/duration/durationInput.js +14 -8
- package/lib/components/duration/durationUtils.js +38 -8
- package/lib/components/input/html/__snapshots__/input.spec.tsx.snap +2 -0
- package/lib/components/input/html/input.js +3 -3
- package/lib/components/input/lunatic-input.js +2 -1
- package/lib/components/input-number/html/__snapshots__/input-number.spec.tsx.snap +2 -2
- package/lib/components/input-number/html/input-number-thousand.js +4 -17
- package/lib/components/input-number/html/input-number.js +3 -5
- package/lib/components/input-number/lunatic-input-number.js +2 -3
- package/lib/components/loop/block-for-loop.js +3 -3
- package/lib/components/loop/roster-for-loop/__snapshots__/roster-for-loop.spec.tsx.snap +88 -0
- package/lib/components/loop/roster-for-loop/roster-for-loop.js +7 -3
- package/lib/components/loop/roster-for-loop/roster-for-loop.spec.js +46 -0
- package/lib/components/lunatic-components.js +2 -11
- package/lib/components/radio/html/radio-group-content.js +4 -2
- package/lib/components/radio/html/radio-group.js +3 -3
- package/lib/components/radio/html/radio-option.js +3 -1
- package/lib/components/radio/lunatic-radio-group.js +2 -1
- package/lib/components/suggester/find-best-label/find-best-label.js +5 -5
- package/lib/components/suggester/idb-suggester/check-store.js +6 -3
- package/lib/components/suggester/idb-suggester/idb-suggester.js +8 -7
- package/lib/components/suggester/idb-suggester/suggester-status.js +1 -4
- package/lib/components/suggester/lunatic-suggester.js +7 -4
- package/lib/components/suggester/searching/create-searching.js +19 -42
- package/lib/components/suggester-loader-widget/loader-row.js +4 -2
- package/lib/components/suggester-loader-widget/loader.js +5 -4
- package/lib/components/suggester-loader-widget/widget.js +8 -8
- package/lib/components/switch/html/switch.js +2 -2
- package/lib/components/switch/lunatic-switch.js +2 -1
- package/lib/components/table/lunatic-table.js +2 -2
- package/lib/components/textarea/html/__snapshots__/textarea.spec.tsx.snap +2 -0
- package/lib/components/textarea/html/textarea.js +6 -4
- package/lib/components/textarea/lunatic-textarea.js +6 -3
- package/lib/hooks/use-auto-focus.js +26 -0
- package/lib/src/components/checkbox/checkbox-boolean/html/checkbox-boolean.d.ts +1 -1
- package/lib/src/components/checkbox/checkbox-group/html/checkbox-group-content.d.ts +2 -1
- package/lib/src/components/checkbox/checkbox-group/html/checkbox-group.d.ts +1 -1
- package/lib/src/components/checkbox/commons/checkbox-option.d.ts +1 -0
- package/lib/src/components/commons/components/combo-box/combo-box-container.d.ts +2 -2
- package/lib/src/components/commons/components/combo-box/combo-box.d.ts +2 -2
- package/lib/src/components/commons/components/combo-box/selection/LabelOrInput.d.ts +1 -0
- package/lib/src/components/commons/components/combo-box/selection/input.d.ts +1 -0
- package/lib/src/components/commons/components/combo-box/selection/selection.d.ts +2 -1
- package/lib/src/components/commons/components/errors/errors.d.ts +6 -3
- package/lib/src/components/datepicker/html/DatepickerField.d.ts +12 -0
- package/lib/src/components/datepicker/html/datepicker.d.ts +4 -3
- package/lib/src/components/datepicker/lunatic-datepicker.d.ts +1 -0
- package/lib/src/components/dropdown/html/dropdown-writable/dropdown-writable.d.ts +1 -1
- package/lib/src/components/dropdown/html/dropdown.d.ts +3 -1
- package/lib/src/components/duration/durationInput.d.ts +6 -2
- package/lib/src/components/duration/durationUtils.d.ts +24 -7
- package/lib/src/components/input/html/input.d.ts +2 -2
- package/lib/src/components/input-number/html/input-number-thousand.d.ts +2 -2
- package/lib/src/components/input-number/html/input-number.d.ts +2 -3
- package/lib/src/components/radio/html/radio-group-content.d.ts +2 -1
- package/lib/src/components/radio/html/radio-group.d.ts +1 -1
- package/lib/src/components/radio/html/radio-option.d.ts +1 -0
- package/lib/src/components/suggester/find-best-label/find-best-label.d.ts +1 -1
- package/lib/src/components/suggester/html/suggester.d.ts +1 -1
- package/lib/src/components/suggester/idb-suggester/check-store.d.ts +5 -2
- package/lib/src/components/suggester/idb-suggester/idb-suggester.d.ts +5 -2
- package/lib/src/components/suggester/idb-suggester/suggester-status.d.ts +1 -4
- package/lib/src/components/suggester/lunatic-suggester.d.ts +1 -1
- package/lib/src/components/suggester/searching/create-searching.d.ts +1 -1
- package/lib/src/components/suggester-loader-widget/loader-row.d.ts +2 -1
- package/lib/src/components/suggester-loader-widget/loader.d.ts +2 -1
- package/lib/src/components/suggester-loader-widget/widget.d.ts +3 -2
- package/lib/src/components/switch/html/switch.d.ts +1 -1
- package/lib/src/components/textarea/html/textarea.d.ts +3 -2
- package/lib/src/components/type.d.ts +5 -3
- package/lib/src/hooks/use-auto-focus.d.ts +6 -0
- package/lib/src/use-lunatic/actions.d.ts +2 -0
- package/lib/src/use-lunatic/commons/fill-components/fill-component-required.d.ts +383 -0
- package/lib/src/use-lunatic/commons/fill-components/fill-component-value.d.ts +1 -1
- package/lib/src/use-lunatic/commons/fill-components/fill-component-value.spec.d.ts +1 -0
- package/lib/src/use-lunatic/commons/fill-components/fill-from-state.d.ts +20 -0
- package/lib/src/use-lunatic/commons/variables/lunatic-variables-store.d.ts +4 -0
- package/lib/src/use-lunatic/reducer/overview/overview-on-init.d.ts +1 -0
- package/lib/src/use-lunatic/type.d.ts +1 -0
- package/lib/src/use-lunatic/use-lunatic.d.ts +8 -3
- package/lib/src/use-lunatic/use-suggesters.d.ts +2 -1
- package/lib/src/utils/suggester-workers/append-to-index/create-append-task.d.ts +2 -2
- package/lib/src/utils/suggester-workers/worker-path.d.ts +6 -0
- package/lib/stories/behaviour/cleaning/source.json +151 -0
- package/lib/stories/behaviour/cleaning/test.stories.js +83 -0
- package/lib/stories/{questionnaires-test → behaviour}/controls/controls.stories.js +5 -5
- package/lib/stories/{questionnaires-test → behaviour/others}/test.stories.js +7 -7
- package/lib/stories/{paste-questionnaire → behaviour/paste}/test.stories.js +5 -4
- package/lib/stories/{resizing-questionnaire → behaviour/resizing}/test.stories.js +5 -4
- package/lib/stories/date-picker/datepicker.stories.js +32 -29
- package/lib/stories/duration/duration.stories.js +4 -4
- package/lib/stories/duration/{source.json → mois.json} +1 -1
- package/lib/stories/duration/{source1.json → time.json} +1 -1
- package/lib/stories/loop/not-paginated-loop.stories.js +35 -0
- package/lib/stories/loop/source-bloc.json +2 -2
- package/lib/stories/loop/source-not-paginated.json +138 -0
- package/lib/stories/loop/source-paginated.json +2 -2
- package/lib/stories/suggester/suggester.stories.js +6 -37
- package/lib/stories/utils/referentiel.js +38 -0
- package/lib/use-lunatic/commons/fill-components/fill-component-required.js +23 -0
- package/lib/use-lunatic/commons/fill-components/fill-component-value.js +1 -1
- package/lib/use-lunatic/commons/fill-components/fill-component-value.spec.js +67 -0
- package/lib/use-lunatic/commons/fill-components/fill-components.js +2 -1
- package/lib/use-lunatic/commons/fill-components/fill-from-state.js +2 -0
- package/lib/use-lunatic/commons/variables/lunatic-variables-store.js +15 -0
- package/lib/use-lunatic/commons/variables/lunatic-variables-store.spec.js +9 -1
- package/lib/use-lunatic/initial-state.js +2 -1
- package/lib/use-lunatic/reducer/reduce-on-init.js +4 -2
- package/lib/use-lunatic/use-lunatic.js +7 -3
- package/lib/use-lunatic/use-suggesters.js +55 -38
- package/lib/utils/env.js +9 -1
- package/lib/utils/suggester-workers/append-to-index/create-append-task.js +5 -4
- package/lib/utils/suggester-workers/create-worker.js +7 -1
- package/lib/utils/suggester-workers/worker-path.js +29 -0
- package/package.json +24 -11
- package/scripts/build/add-workers-to-public.js +44 -0
- package/scripts/build/workers-paths.js +45 -0
- package/workers-release/lunatic-append-worker-0.3.0.js +2 -0
- package/workers-release/lunatic-append-worker-0.3.0.js.LICENSE.txt +34 -0
- package/workers-release/lunatic-label-worker-0.3.0.js +2 -0
- package/workers-release/lunatic-label-worker-0.3.0.js.LICENSE.txt +13 -0
- package/workers-release/lunatic-search-worker-0.3.0.js +2 -0
- package/workers-release/lunatic-search-worker-0.3.0.js.LICENSE.txt +34 -0
- package/lib/components/datepicker/html/datepicker-container.js +0 -17
- package/lib/components/datepicker/html/datepicker-input.js +0 -35
- package/lib/env.d.js +0 -1
- package/lib/src/components/datepicker/html/datepicker-container.d.ts +0 -3
- package/lib/src/components/datepicker/html/datepicker-input.d.ts +0 -13
- package/lib/src/utils/get-component-value.d.ts +0 -5
- package/lib/src/utils/store-tools/worker-path.d.ts +0 -1
- package/lib/utils/get-component-value.js +0 -34
- package/lib/utils/get-component-value.test.js +0 -57
- package/lib/utils/store-tools/worker-path.js +0 -13
- package/lib/utils/suggester-workers/create-worker-ts.js +0 -54
- /package/lib/src/{utils/get-component-value.test.d.ts → components/loop/roster-for-loop/roster-for-loop.spec.d.ts} +0 -0
- /package/lib/src/utils/suggester-workers/{create-worker-ts.d.ts → create-worker.d.ts} +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_ControlesNonNum_horsBoucle_PasPageFin.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_ControlesNum_horsBoucle_PasPageFin.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_Controles_BouclesLiees2_PasPageFin.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/V2_Controles_BouclesLiees_PasPageFin.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/boucles-n.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/controls-externes.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour}/controls/controls-externes.stories.js +0 -0
- /package/lib/stories/{questionnaires-test → behaviour/others}/V2_DeclarationsSimples.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour/others}/V2_MinMaxSum_Boucles.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour/others}/V2_QuestSimple_Boucles.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour/others}/V2_TCMRallyeGames.json +0 -0
- /package/lib/stories/{questionnaires-test → behaviour/others}/test-dylan.json +0 -0
- /package/lib/stories/{paste-questionnaire → behaviour/paste}/source.json +0 -0
- /package/lib/stories/{resizing-questionnaire → behaviour/resizing}/source.json +0 -0
|
@@ -19,10 +19,13 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
19
19
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
20
20
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t["return"] && (u = t["return"](), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
21
21
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
22
|
+
/**
|
|
23
|
+
* Check the store info displaying a message while it is fetching
|
|
24
|
+
*/
|
|
22
25
|
function CheckStore(_ref) {
|
|
23
26
|
var storeName = _ref.storeName,
|
|
24
27
|
version = _ref.version,
|
|
25
|
-
|
|
28
|
+
onInfo = _ref.onInfo,
|
|
26
29
|
children = _ref.children;
|
|
27
30
|
var _useState = (0, _react.useState)(0),
|
|
28
31
|
_useState2 = _slicedToArray(_useState, 2),
|
|
@@ -48,7 +51,7 @@ function CheckStore(_ref) {
|
|
|
48
51
|
info = _context.sent;
|
|
49
52
|
if (db && info) {
|
|
50
53
|
setReady(200);
|
|
51
|
-
|
|
54
|
+
onInfo(info);
|
|
52
55
|
}
|
|
53
56
|
_context.next = 13;
|
|
54
57
|
break;
|
|
@@ -61,7 +64,7 @@ function CheckStore(_ref) {
|
|
|
61
64
|
return _context.stop();
|
|
62
65
|
}
|
|
63
66
|
}, _callee, null, [[0, 10]]);
|
|
64
|
-
})), [storeName, version,
|
|
67
|
+
})), [storeName, version, onInfo]);
|
|
65
68
|
(0, _react.useEffect)(function () {
|
|
66
69
|
checkStore();
|
|
67
70
|
}, [checkStore]);
|
|
@@ -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
|
-
|
|
39
|
-
|
|
39
|
+
storeInfo = _useState2[0],
|
|
40
|
+
setStoreInfo = _useState2[1];
|
|
40
41
|
var searching = (0, _react.useMemo)(function () {
|
|
41
|
-
if (
|
|
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,
|
|
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
|
-
|
|
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
|
-
*
|
|
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
|
|
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
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
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",
|
|
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();
|
|
@@ -4,12 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports["default"] = void 0;
|
|
7
|
-
var _react = require("react");
|
|
8
7
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
8
|
+
var _react = require("react");
|
|
9
|
+
var _logger = require("../../utils/logger");
|
|
9
10
|
var _storeTools = require("../../utils/store-tools");
|
|
10
11
|
var _icons = require("../commons/icons");
|
|
11
12
|
var _loader = _interopRequireDefault(require("./loader"));
|
|
12
|
-
var _logger = require("../../utils/logger");
|
|
13
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
15
|
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
@@ -20,6 +20,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
20
20
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
21
21
|
function LoaderRow(_ref) {
|
|
22
22
|
var storeInfo = _ref.storeInfo,
|
|
23
|
+
workersBasePath = _ref.workersBasePath,
|
|
23
24
|
idbVersion = _ref.idbVersion,
|
|
24
25
|
fetchStore = _ref.fetchStore,
|
|
25
26
|
onRefresh = _ref.onRefresh,
|
|
@@ -65,6 +66,7 @@ function LoaderRow(_ref) {
|
|
|
65
66
|
db: db,
|
|
66
67
|
store: storeInfo,
|
|
67
68
|
idbVersion: idbVersion,
|
|
69
|
+
workersBasePath: workersBasePath,
|
|
68
70
|
fetch: fetchStore,
|
|
69
71
|
post: post,
|
|
70
72
|
handleClick: handleClick
|
|
@@ -6,10 +6,10 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
6
6
|
});
|
|
7
7
|
exports["default"] = void 0;
|
|
8
8
|
var _react = require("react");
|
|
9
|
+
var _function = require("../../utils/function");
|
|
10
|
+
var _storeTools = require("../../utils/store-tools");
|
|
9
11
|
var _appendToIndex = require("../../utils/suggester-workers/append-to-index");
|
|
10
12
|
var _progress = _interopRequireDefault(require("./progress"));
|
|
11
|
-
var _storeTools = require("../../utils/store-tools");
|
|
12
|
-
var _function = require("../../utils/function");
|
|
13
13
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
14
14
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
15
15
|
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return e; }; var t, e = {}, r = Object.prototype, n = r.hasOwnProperty, o = Object.defineProperty || function (t, e, r) { t[e] = r.value; }, i = "function" == typeof Symbol ? Symbol : {}, a = i.iterator || "@@iterator", c = i.asyncIterator || "@@asyncIterator", u = i.toStringTag || "@@toStringTag"; function define(t, e, r) { return Object.defineProperty(t, e, { value: r, enumerable: !0, configurable: !0, writable: !0 }), t[e]; } try { define({}, ""); } catch (t) { define = function define(t, e, r) { return t[e] = r; }; } function wrap(t, e, r, n) { var i = e && e.prototype instanceof Generator ? e : Generator, a = Object.create(i.prototype), c = new Context(n || []); return o(a, "_invoke", { value: makeInvokeMethod(t, r, c) }), a; } function tryCatch(t, e, r) { try { return { type: "normal", arg: t.call(e, r) }; } catch (t) { return { type: "throw", arg: t }; } } e.wrap = wrap; var h = "suspendedStart", l = "suspendedYield", f = "executing", s = "completed", y = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var p = {}; define(p, a, function () { return this; }); var d = Object.getPrototypeOf, v = d && d(d(values([]))); v && v !== r && n.call(v, a) && (p = v); var g = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(p); function defineIteratorMethods(t) { ["next", "throw", "return"].forEach(function (e) { define(t, e, function (t) { return this._invoke(e, t); }); }); } function AsyncIterator(t, e) { function invoke(r, o, i, a) { var c = tryCatch(t[r], t, o); if ("throw" !== c.type) { var u = c.arg, h = u.value; return h && "object" == _typeof(h) && n.call(h, "__await") ? e.resolve(h.__await).then(function (t) { invoke("next", t, i, a); }, function (t) { invoke("throw", t, i, a); }) : e.resolve(h).then(function (t) { u.value = t, i(u); }, function (t) { return invoke("throw", t, i, a); }); } a(c.arg); } var r; o(this, "_invoke", { value: function value(t, n) { function callInvokeWithMethodAndArg() { return new e(function (e, r) { invoke(t, n, e, r); }); } return r = r ? r.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); } }); } function makeInvokeMethod(e, r, n) { var o = h; return function (i, a) { if (o === f) throw new Error("Generator is already running"); if (o === s) { if ("throw" === i) throw a; return { value: t, done: !0 }; } for (n.method = i, n.arg = a;;) { var c = n.delegate; if (c) { var u = maybeInvokeDelegate(c, n); if (u) { if (u === y) continue; return u; } } if ("next" === n.method) n.sent = n._sent = n.arg;else if ("throw" === n.method) { if (o === h) throw o = s, n.arg; n.dispatchException(n.arg); } else "return" === n.method && n.abrupt("return", n.arg); o = f; var p = tryCatch(e, r, n); if ("normal" === p.type) { if (o = n.done ? s : l, p.arg === y) continue; return { value: p.arg, done: n.done }; } "throw" === p.type && (o = s, n.method = "throw", n.arg = p.arg); } }; } function maybeInvokeDelegate(e, r) { var n = r.method, o = e.iterator[n]; if (o === t) return r.delegate = null, "throw" === n && e.iterator["return"] && (r.method = "return", r.arg = t, maybeInvokeDelegate(e, r), "throw" === r.method) || "return" !== n && (r.method = "throw", r.arg = new TypeError("The iterator does not provide a '" + n + "' method")), y; var i = tryCatch(o, e.iterator, r.arg); if ("throw" === i.type) return r.method = "throw", r.arg = i.arg, r.delegate = null, y; var a = i.arg; return a ? a.done ? (r[e.resultName] = a.value, r.next = e.nextLoc, "return" !== r.method && (r.method = "next", r.arg = t), r.delegate = null, y) : a : (r.method = "throw", r.arg = new TypeError("iterator result is not an object"), r.delegate = null, y); } function pushTryEntry(t) { var e = { tryLoc: t[0] }; 1 in t && (e.catchLoc = t[1]), 2 in t && (e.finallyLoc = t[2], e.afterLoc = t[3]), this.tryEntries.push(e); } function resetTryEntry(t) { var e = t.completion || {}; e.type = "normal", delete e.arg, t.completion = e; } function Context(t) { this.tryEntries = [{ tryLoc: "root" }], t.forEach(pushTryEntry, this), this.reset(!0); } function values(e) { if (e || "" === e) { var r = e[a]; if (r) return r.call(e); if ("function" == typeof e.next) return e; if (!isNaN(e.length)) { var o = -1, i = function next() { for (; ++o < e.length;) if (n.call(e, o)) return next.value = e[o], next.done = !1, next; return next.value = t, next.done = !0, next; }; return i.next = i; } } throw new TypeError(_typeof(e) + " is not iterable"); } return GeneratorFunction.prototype = GeneratorFunctionPrototype, o(g, "constructor", { value: GeneratorFunctionPrototype, configurable: !0 }), o(GeneratorFunctionPrototype, "constructor", { value: GeneratorFunction, configurable: !0 }), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, u, "GeneratorFunction"), e.isGeneratorFunction = function (t) { var e = "function" == typeof t && t.constructor; return !!e && (e === GeneratorFunction || "GeneratorFunction" === (e.displayName || e.name)); }, e.mark = function (t) { return Object.setPrototypeOf ? Object.setPrototypeOf(t, GeneratorFunctionPrototype) : (t.__proto__ = GeneratorFunctionPrototype, define(t, u, "GeneratorFunction")), t.prototype = Object.create(g), t; }, e.awrap = function (t) { return { __await: t }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, c, function () { return this; }), e.AsyncIterator = AsyncIterator, e.async = function (t, r, n, o, i) { void 0 === i && (i = Promise); var a = new AsyncIterator(wrap(t, r, n, o), i); return e.isGeneratorFunction(r) ? a : a.next().then(function (t) { return t.done ? t.value : a.next(); }); }, defineIteratorMethods(g), define(g, u, "Generator"), define(g, a, function () { return this; }), define(g, "toString", function () { return "[object Generator]"; }), e.keys = function (t) { var e = Object(t), r = []; for (var n in e) r.push(n); return r.reverse(), function next() { for (; r.length;) { var t = r.pop(); if (t in e) return next.value = t, next.done = !1, next; } return next.done = !0, next; }; }, e.values = values, Context.prototype = { constructor: Context, reset: function reset(e) { if (this.prev = 0, this.next = 0, this.sent = this._sent = t, this.done = !1, this.delegate = null, this.method = "next", this.arg = t, this.tryEntries.forEach(resetTryEntry), !e) for (var r in this) "t" === r.charAt(0) && n.call(this, r) && !isNaN(+r.slice(1)) && (this[r] = t); }, stop: function stop() { this.done = !0; var t = this.tryEntries[0].completion; if ("throw" === t.type) throw t.arg; return this.rval; }, dispatchException: function dispatchException(e) { if (this.done) throw e; var r = this; function handle(n, o) { return a.type = "throw", a.arg = e, r.next = n, o && (r.method = "next", r.arg = t), !!o; } for (var o = this.tryEntries.length - 1; o >= 0; --o) { var i = this.tryEntries[o], a = i.completion; if ("root" === i.tryLoc) return handle("end"); if (i.tryLoc <= this.prev) { var c = n.call(i, "catchLoc"), u = n.call(i, "finallyLoc"); if (c && u) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } else if (c) { if (this.prev < i.catchLoc) return handle(i.catchLoc, !0); } else { if (!u) throw new Error("try statement without catch or finally"); if (this.prev < i.finallyLoc) return handle(i.finallyLoc); } } } }, abrupt: function abrupt(t, e) { for (var r = this.tryEntries.length - 1; r >= 0; --r) { var o = this.tryEntries[r]; if (o.tryLoc <= this.prev && n.call(o, "finallyLoc") && this.prev < o.finallyLoc) { var i = o; break; } } i && ("break" === t || "continue" === t) && i.tryLoc <= e && e <= i.finallyLoc && (i = null); var a = i ? i.completion : {}; return a.type = t, a.arg = e, i ? (this.method = "next", this.next = i.finallyLoc, y) : this.complete(a); }, complete: function complete(t, e) { if ("throw" === t.type) throw t.arg; return "break" === t.type || "continue" === t.type ? this.next = t.arg : "return" === t.type ? (this.rval = this.arg = t.arg, this.method = "return", this.next = "end") : "normal" === t.type && e && (this.next = e), y; }, finish: function finish(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.finallyLoc === t) return this.complete(r.completion, r.afterLoc), resetTryEntry(r), y; } }, "catch": function _catch(t) { for (var e = this.tryEntries.length - 1; e >= 0; --e) { var r = this.tryEntries[e]; if (r.tryLoc === t) { var n = r.completion; if ("throw" === n.type) { var o = n.arg; resetTryEntry(r); } return o; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(e, r, n) { return this.delegate = { iterator: values(e), resultName: r, nextLoc: n }, "next" === this.method && (this.arg = t), y; } }, e; }
|
|
@@ -25,6 +25,7 @@ function Loader(_ref) {
|
|
|
25
25
|
var start = _ref.start,
|
|
26
26
|
db = _ref.db,
|
|
27
27
|
store = _ref.store,
|
|
28
|
+
workersBasePath = _ref.workersBasePath,
|
|
28
29
|
_ref$idbVersion = _ref.idbVersion,
|
|
29
30
|
idbVersion = _ref$idbVersion === void 0 ? 1 : _ref$idbVersion,
|
|
30
31
|
fetch = _ref.fetch,
|
|
@@ -93,7 +94,7 @@ function Loader(_ref) {
|
|
|
93
94
|
_context2.next = 8;
|
|
94
95
|
break;
|
|
95
96
|
}
|
|
96
|
-
_createAppendTask = (0, _appendToIndex.createAppendTask)(store, idbVersion, log), _createAppendTask2 = _slicedToArray(_createAppendTask, 2), startT = _createAppendTask2[0], abort_ = _createAppendTask2[1];
|
|
97
|
+
_createAppendTask = (0, _appendToIndex.createAppendTask)(store, idbVersion, log, workersBasePath), _createAppendTask2 = _slicedToArray(_createAppendTask, 2), startT = _createAppendTask2[0], abort_ = _createAppendTask2[1];
|
|
97
98
|
abort = abort_;
|
|
98
99
|
(0, _storeTools.clearStoreData)(db);
|
|
99
100
|
_context2.next = 7;
|
|
@@ -121,7 +122,7 @@ function Loader(_ref) {
|
|
|
121
122
|
abort();
|
|
122
123
|
}
|
|
123
124
|
};
|
|
124
|
-
}, [store, db, entities, idbVersion, post]);
|
|
125
|
+
}, [store, db, entities, idbVersion, post, workersBasePath]);
|
|
125
126
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_progress["default"], {
|
|
126
127
|
percent: progress,
|
|
127
128
|
display: true,
|
|
@@ -5,20 +5,18 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
value: true
|
|
6
6
|
});
|
|
7
7
|
exports["default"] = void 0;
|
|
8
|
-
var _react = _interopRequireWildcard(require("react"));
|
|
9
8
|
var _classnames = _interopRequireDefault(require("classnames"));
|
|
9
|
+
var _react = require("react");
|
|
10
|
+
var _function = require("../../utils/function");
|
|
11
|
+
var _dragger = _interopRequireDefault(require("../commons/components/dragger"));
|
|
12
|
+
var _isNetwork = require("../commons/components/is-network");
|
|
13
|
+
var _icons = require("../commons/icons");
|
|
10
14
|
var _loaderRow = _interopRequireDefault(require("./loader-row"));
|
|
11
15
|
var _tools = require("./tools");
|
|
12
|
-
var _isNetwork = require("../commons/components/is-network");
|
|
13
16
|
var _widgetContainer = _interopRequireDefault(require("./widget-container"));
|
|
14
|
-
var _dragger = _interopRequireDefault(require("../commons/components/dragger"));
|
|
15
|
-
var _icons = require("../commons/icons");
|
|
16
17
|
require("./widget.scss");
|
|
17
|
-
var _function = require("../../utils/function");
|
|
18
18
|
var _jsxRuntime = require("react/jsx-runtime");
|
|
19
19
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
20
|
-
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(e) { return e ? t : r; })(e); }
|
|
21
|
-
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != _typeof(e) && "function" != typeof e) return { "default": e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && Object.prototype.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n["default"] = e, t && t.set(e, n), n; }
|
|
22
20
|
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; }
|
|
23
21
|
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; }
|
|
24
22
|
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; }
|
|
@@ -32,6 +30,7 @@ function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" !=
|
|
|
32
30
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
33
31
|
function SuggesterLoaderWidget(_ref) {
|
|
34
32
|
var source = _ref.source,
|
|
33
|
+
workersBasePath = _ref.workersBasePath,
|
|
35
34
|
getStoreInfo = _ref.getStoreInfo,
|
|
36
35
|
_ref$onRefresh = _ref.onRefresh,
|
|
37
36
|
onRefresh = _ref$onRefresh === void 0 ? _function.voidFunction : _ref$onRefresh,
|
|
@@ -87,6 +86,7 @@ function SuggesterLoaderWidget(_ref) {
|
|
|
87
86
|
fetchStore = _ref3$.fetch;
|
|
88
87
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_loaderRow["default"], {
|
|
89
88
|
storeInfo: storeInfo,
|
|
89
|
+
workersBasePath: workersBasePath,
|
|
90
90
|
idbVersion: idbVersion,
|
|
91
91
|
fetchStore: fetchStore,
|
|
92
92
|
onRefresh: onRefresh,
|
|
@@ -94,7 +94,7 @@ function SuggesterLoaderWidget(_ref) {
|
|
|
94
94
|
}, name);
|
|
95
95
|
}));
|
|
96
96
|
}
|
|
97
|
-
}, [stores, disabled, onRefresh]);
|
|
97
|
+
}, [stores, disabled, onRefresh, workersBasePath]);
|
|
98
98
|
(0, _react.useEffect)(function () {
|
|
99
99
|
if (current && absolute) {
|
|
100
100
|
current.style.top = '30px';
|
|
@@ -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?:
|
|
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?:
|
|
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 {
|
|
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?:
|
|
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?:
|
|
16
|
+
errors?: LunaticError[];
|
|
17
17
|
onChange?: (s: string | null) => void;
|
|
18
18
|
onSelect: (s: string | null) => void;
|
|
19
19
|
options: ComboBoxOptionType[];
|
|
@@ -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;
|