@inseefr/lunatic 2.0.2-v2 → 2.0.3-v2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/components/modal-controls/modal-container.js +1 -1
- package/lib/components/modal-controls/modal-controls.scss +2 -1
- package/lib/stories/checkboxBoolean/checkboxBoolean.stories.js +35 -0
- package/lib/stories/checkboxBoolean/source.json +36 -0
- package/lib/stories/date-picker/datepicker.stories.js +3 -1
- package/lib/stories/date-picker/source.json +2 -51
- package/lib/stories/dropdown/dropdown.stories.js +4 -1
- package/lib/stories/suggester/suggester-workers.stories.js +242 -0
- package/lib/utils/suggester-workers/commons-tokenizer/create-entity-tokenizer.js +7 -1
- package/package.json +3 -2
|
@@ -16,7 +16,7 @@ function ModalContainer(_ref) {
|
|
|
16
16
|
return /*#__PURE__*/_reactDom["default"].createPortal( /*#__PURE__*/_react["default"].createElement("div", {
|
|
17
17
|
className: "lunatic-modal-controls"
|
|
18
18
|
}, /*#__PURE__*/_react["default"].createElement("div", {
|
|
19
|
-
className: "modal"
|
|
19
|
+
className: "modal-content"
|
|
20
20
|
}, children)), document.body);
|
|
21
21
|
}
|
|
22
22
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports["default"] = exports.Default = void 0;
|
|
7
|
+
|
|
8
|
+
var _react = _interopRequireDefault(require("react"));
|
|
9
|
+
|
|
10
|
+
var _orchestrator = _interopRequireDefault(require("../utils/orchestrator"));
|
|
11
|
+
|
|
12
|
+
var _source = _interopRequireDefault(require("./source"));
|
|
13
|
+
|
|
14
|
+
var _defaultArgTypes = _interopRequireDefault(require("../utils/default-arg-types"));
|
|
15
|
+
|
|
16
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
17
|
+
|
|
18
|
+
var stories = {
|
|
19
|
+
title: 'Components/Checkboolean',
|
|
20
|
+
component: _orchestrator["default"],
|
|
21
|
+
argTypes: _defaultArgTypes["default"]
|
|
22
|
+
};
|
|
23
|
+
var _default = stories;
|
|
24
|
+
exports["default"] = _default;
|
|
25
|
+
|
|
26
|
+
var Template = function Template(args) {
|
|
27
|
+
return /*#__PURE__*/_react["default"].createElement(_orchestrator["default"], args);
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
var Default = Template.bind({});
|
|
31
|
+
exports.Default = Default;
|
|
32
|
+
Default.args = {
|
|
33
|
+
id: 'checkboxBoolean',
|
|
34
|
+
source: _source["default"]
|
|
35
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
{
|
|
2
|
+
"components": [
|
|
3
|
+
{
|
|
4
|
+
"id": "checkboxboolean",
|
|
5
|
+
"componentType": "CheckboxBoolean",
|
|
6
|
+
"mandatory": false,
|
|
7
|
+
"page": "1",
|
|
8
|
+
"label": {
|
|
9
|
+
"value": "checkboxBoolean component (checked: true, unchecked: false)",
|
|
10
|
+
"type": "VTL|MD"
|
|
11
|
+
},
|
|
12
|
+
|
|
13
|
+
"conditionFilter": { "value": "true", "type": "VTL" },
|
|
14
|
+
|
|
15
|
+
"options": [
|
|
16
|
+
{ "value": "1", "label": { "value": "oui", "type": "VTL|MD" } },
|
|
17
|
+
|
|
18
|
+
{ "value": "2", "label": { "value": "non", "type": "VTL|MD" } }
|
|
19
|
+
],
|
|
20
|
+
"response": { "name": "Q2" }
|
|
21
|
+
}
|
|
22
|
+
],
|
|
23
|
+
"variables": [
|
|
24
|
+
{
|
|
25
|
+
"variableType": "COLLECTED",
|
|
26
|
+
"name": "Q2",
|
|
27
|
+
"values": {
|
|
28
|
+
"PREVIOUS": null,
|
|
29
|
+
"COLLECTED": null,
|
|
30
|
+
"FORCED": null,
|
|
31
|
+
"EDITED": null,
|
|
32
|
+
"INPUTED": null
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
]
|
|
36
|
+
}
|
|
@@ -31,20 +31,6 @@
|
|
|
31
31
|
}
|
|
32
32
|
],
|
|
33
33
|
"components": [
|
|
34
|
-
{
|
|
35
|
-
"componentType": "Sequence",
|
|
36
|
-
"hierarchy": {
|
|
37
|
-
"sequence": {
|
|
38
|
-
"id": "l7ovaca8",
|
|
39
|
-
"page": "1",
|
|
40
|
-
"label": { "type": "VTL|MD", "value": "\"I - \" || \"S1\"" }
|
|
41
|
-
}
|
|
42
|
-
},
|
|
43
|
-
"conditionFilter": { "type": "VTL", "value": "true" },
|
|
44
|
-
"id": "l7ovaca8",
|
|
45
|
-
"page": "1",
|
|
46
|
-
"label": { "type": "VTL|MD", "value": "\"I - \" || \"S1\"" }
|
|
47
|
-
},
|
|
48
34
|
{
|
|
49
35
|
"componentType": "Datepicker",
|
|
50
36
|
"controls": [
|
|
@@ -89,42 +75,7 @@
|
|
|
89
75
|
"min": "1900-01-01",
|
|
90
76
|
"response": { "name": "Q1" },
|
|
91
77
|
"id": "l7ovm2rv",
|
|
92
|
-
"page": "
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
"componentType": "Sequence",
|
|
96
|
-
"hierarchy": {
|
|
97
|
-
"sequence": {
|
|
98
|
-
"id": "COMMENT-SEQ",
|
|
99
|
-
"page": "3",
|
|
100
|
-
"label": { "type": "VTL|MD", "value": "\"Commentaire\"" }
|
|
101
|
-
}
|
|
102
|
-
},
|
|
103
|
-
"conditionFilter": { "type": "VTL", "value": "true" },
|
|
104
|
-
"id": "COMMENT-SEQ",
|
|
105
|
-
"page": "3",
|
|
106
|
-
"label": { "type": "VTL|MD", "value": "\"Commentaire\"" }
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
"componentType": "Textarea",
|
|
110
|
-
"bindingDependencies": ["COMMENT_QE"],
|
|
111
|
-
"response": { "name": "COMMENT_QE" },
|
|
112
|
-
"hierarchy": {
|
|
113
|
-
"sequence": {
|
|
114
|
-
"id": "COMMENT-SEQ",
|
|
115
|
-
"page": "3",
|
|
116
|
-
"label": { "type": "VTL|MD", "value": "\"Commentaire\"" }
|
|
117
|
-
}
|
|
118
|
-
},
|
|
119
|
-
"conditionFilter": { "type": "VTL", "value": "true" },
|
|
120
|
-
"id": "COMMENT-QUESTION",
|
|
121
|
-
"page": "4",
|
|
122
|
-
"label": {
|
|
123
|
-
"type": "VTL|MD",
|
|
124
|
-
"value": "\"Avez-vous des remarques concernant l'enquête ou des commentaires ?\""
|
|
125
|
-
},
|
|
126
|
-
"mandatory": false,
|
|
127
|
-
"maxLength": 2000
|
|
78
|
+
"page": "1"
|
|
128
79
|
}
|
|
129
80
|
],
|
|
130
81
|
"pagination": "question",
|
|
@@ -136,5 +87,5 @@
|
|
|
136
87
|
"generatingDate": "05-09-2022 14:37:43",
|
|
137
88
|
"missing": false,
|
|
138
89
|
"id": "l7ovbqou",
|
|
139
|
-
"maxPage": "
|
|
90
|
+
"maxPage": "1"
|
|
140
91
|
}
|
|
@@ -0,0 +1,242 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports["default"] = exports.Default = void 0;
|
|
9
|
+
|
|
10
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
11
|
+
|
|
12
|
+
var _orchestrator = _interopRequireDefault(require("../utils/orchestrator"));
|
|
13
|
+
|
|
14
|
+
var _defaultArgTypes = _interopRequireDefault(require("../utils/default-arg-types"));
|
|
15
|
+
|
|
16
|
+
var _idbTools = require("../../utils/idb-tools");
|
|
17
|
+
|
|
18
|
+
var _storeTools = require("../../utils/store-tools");
|
|
19
|
+
|
|
20
|
+
var _appendToIndex = _interopRequireDefault(require("../../utils/suggester-workers/append-to-index"));
|
|
21
|
+
|
|
22
|
+
var _searching = _interopRequireDefault(require("../../utils/suggester-workers/searching"));
|
|
23
|
+
|
|
24
|
+
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
|
|
25
|
+
|
|
26
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
27
|
+
|
|
28
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
29
|
+
|
|
30
|
+
function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyright (c) 2014-present, Facebook, Inc. -- license (MIT): https://github.com/facebook/regenerator/blob/main/LICENSE */ _regeneratorRuntime = function _regeneratorRuntime() { return exports; }; var exports = {}, Op = Object.prototype, hasOwn = Op.hasOwnProperty, $Symbol = "function" == typeof Symbol ? Symbol : {}, iteratorSymbol = $Symbol.iterator || "@@iterator", asyncIteratorSymbol = $Symbol.asyncIterator || "@@asyncIterator", toStringTagSymbol = $Symbol.toStringTag || "@@toStringTag"; function define(obj, key, value) { return Object.defineProperty(obj, key, { value: value, enumerable: !0, configurable: !0, writable: !0 }), obj[key]; } try { define({}, ""); } catch (err) { define = function define(obj, key, value) { return obj[key] = value; }; } function wrap(innerFn, outerFn, self, tryLocsList) { var protoGenerator = outerFn && outerFn.prototype instanceof Generator ? outerFn : Generator, generator = Object.create(protoGenerator.prototype), context = new Context(tryLocsList || []); return generator._invoke = function (innerFn, self, context) { var state = "suspendedStart"; return function (method, arg) { if ("executing" === state) throw new Error("Generator is already running"); if ("completed" === state) { if ("throw" === method) throw arg; return doneResult(); } for (context.method = method, context.arg = arg;;) { var delegate = context.delegate; if (delegate) { var delegateResult = maybeInvokeDelegate(delegate, context); if (delegateResult) { if (delegateResult === ContinueSentinel) continue; return delegateResult; } } if ("next" === context.method) context.sent = context._sent = context.arg;else if ("throw" === context.method) { if ("suspendedStart" === state) throw state = "completed", context.arg; context.dispatchException(context.arg); } else "return" === context.method && context.abrupt("return", context.arg); state = "executing"; var record = tryCatch(innerFn, self, context); if ("normal" === record.type) { if (state = context.done ? "completed" : "suspendedYield", record.arg === ContinueSentinel) continue; return { value: record.arg, done: context.done }; } "throw" === record.type && (state = "completed", context.method = "throw", context.arg = record.arg); } }; }(innerFn, self, context), generator; } function tryCatch(fn, obj, arg) { try { return { type: "normal", arg: fn.call(obj, arg) }; } catch (err) { return { type: "throw", arg: err }; } } exports.wrap = wrap; var ContinueSentinel = {}; function Generator() {} function GeneratorFunction() {} function GeneratorFunctionPrototype() {} var IteratorPrototype = {}; define(IteratorPrototype, iteratorSymbol, function () { return this; }); var getProto = Object.getPrototypeOf, NativeIteratorPrototype = getProto && getProto(getProto(values([]))); NativeIteratorPrototype && NativeIteratorPrototype !== Op && hasOwn.call(NativeIteratorPrototype, iteratorSymbol) && (IteratorPrototype = NativeIteratorPrototype); var Gp = GeneratorFunctionPrototype.prototype = Generator.prototype = Object.create(IteratorPrototype); function defineIteratorMethods(prototype) { ["next", "throw", "return"].forEach(function (method) { define(prototype, method, function (arg) { return this._invoke(method, arg); }); }); } function AsyncIterator(generator, PromiseImpl) { function invoke(method, arg, resolve, reject) { var record = tryCatch(generator[method], generator, arg); if ("throw" !== record.type) { var result = record.arg, value = result.value; return value && "object" == _typeof(value) && hasOwn.call(value, "__await") ? PromiseImpl.resolve(value.__await).then(function (value) { invoke("next", value, resolve, reject); }, function (err) { invoke("throw", err, resolve, reject); }) : PromiseImpl.resolve(value).then(function (unwrapped) { result.value = unwrapped, resolve(result); }, function (error) { return invoke("throw", error, resolve, reject); }); } reject(record.arg); } var previousPromise; this._invoke = function (method, arg) { function callInvokeWithMethodAndArg() { return new PromiseImpl(function (resolve, reject) { invoke(method, arg, resolve, reject); }); } return previousPromise = previousPromise ? previousPromise.then(callInvokeWithMethodAndArg, callInvokeWithMethodAndArg) : callInvokeWithMethodAndArg(); }; } function maybeInvokeDelegate(delegate, context) { var method = delegate.iterator[context.method]; if (undefined === method) { if (context.delegate = null, "throw" === context.method) { if (delegate.iterator["return"] && (context.method = "return", context.arg = undefined, maybeInvokeDelegate(delegate, context), "throw" === context.method)) return ContinueSentinel; context.method = "throw", context.arg = new TypeError("The iterator does not provide a 'throw' method"); } return ContinueSentinel; } var record = tryCatch(method, delegate.iterator, context.arg); if ("throw" === record.type) return context.method = "throw", context.arg = record.arg, context.delegate = null, ContinueSentinel; var info = record.arg; return info ? info.done ? (context[delegate.resultName] = info.value, context.next = delegate.nextLoc, "return" !== context.method && (context.method = "next", context.arg = undefined), context.delegate = null, ContinueSentinel) : info : (context.method = "throw", context.arg = new TypeError("iterator result is not an object"), context.delegate = null, ContinueSentinel); } function pushTryEntry(locs) { var entry = { tryLoc: locs[0] }; 1 in locs && (entry.catchLoc = locs[1]), 2 in locs && (entry.finallyLoc = locs[2], entry.afterLoc = locs[3]), this.tryEntries.push(entry); } function resetTryEntry(entry) { var record = entry.completion || {}; record.type = "normal", delete record.arg, entry.completion = record; } function Context(tryLocsList) { this.tryEntries = [{ tryLoc: "root" }], tryLocsList.forEach(pushTryEntry, this), this.reset(!0); } function values(iterable) { if (iterable) { var iteratorMethod = iterable[iteratorSymbol]; if (iteratorMethod) return iteratorMethod.call(iterable); if ("function" == typeof iterable.next) return iterable; if (!isNaN(iterable.length)) { var i = -1, next = function next() { for (; ++i < iterable.length;) { if (hasOwn.call(iterable, i)) return next.value = iterable[i], next.done = !1, next; } return next.value = undefined, next.done = !0, next; }; return next.next = next; } } return { next: doneResult }; } function doneResult() { return { value: undefined, done: !0 }; } return GeneratorFunction.prototype = GeneratorFunctionPrototype, define(Gp, "constructor", GeneratorFunctionPrototype), define(GeneratorFunctionPrototype, "constructor", GeneratorFunction), GeneratorFunction.displayName = define(GeneratorFunctionPrototype, toStringTagSymbol, "GeneratorFunction"), exports.isGeneratorFunction = function (genFun) { var ctor = "function" == typeof genFun && genFun.constructor; return !!ctor && (ctor === GeneratorFunction || "GeneratorFunction" === (ctor.displayName || ctor.name)); }, exports.mark = function (genFun) { return Object.setPrototypeOf ? Object.setPrototypeOf(genFun, GeneratorFunctionPrototype) : (genFun.__proto__ = GeneratorFunctionPrototype, define(genFun, toStringTagSymbol, "GeneratorFunction")), genFun.prototype = Object.create(Gp), genFun; }, exports.awrap = function (arg) { return { __await: arg }; }, defineIteratorMethods(AsyncIterator.prototype), define(AsyncIterator.prototype, asyncIteratorSymbol, function () { return this; }), exports.AsyncIterator = AsyncIterator, exports.async = function (innerFn, outerFn, self, tryLocsList, PromiseImpl) { void 0 === PromiseImpl && (PromiseImpl = Promise); var iter = new AsyncIterator(wrap(innerFn, outerFn, self, tryLocsList), PromiseImpl); return exports.isGeneratorFunction(outerFn) ? iter : iter.next().then(function (result) { return result.done ? result.value : iter.next(); }); }, defineIteratorMethods(Gp), define(Gp, toStringTagSymbol, "Generator"), define(Gp, iteratorSymbol, function () { return this; }), define(Gp, "toString", function () { return "[object Generator]"; }), exports.keys = function (object) { var keys = []; for (var key in object) { keys.push(key); } return keys.reverse(), function next() { for (; keys.length;) { var key = keys.pop(); if (key in object) return next.value = key, next.done = !1, next; } return next.done = !0, next; }; }, exports.values = values, Context.prototype = { constructor: Context, reset: function reset(skipTempReset) { if (this.prev = 0, this.next = 0, this.sent = this._sent = undefined, this.done = !1, this.delegate = null, this.method = "next", this.arg = undefined, this.tryEntries.forEach(resetTryEntry), !skipTempReset) for (var name in this) { "t" === name.charAt(0) && hasOwn.call(this, name) && !isNaN(+name.slice(1)) && (this[name] = undefined); } }, stop: function stop() { this.done = !0; var rootRecord = this.tryEntries[0].completion; if ("throw" === rootRecord.type) throw rootRecord.arg; return this.rval; }, dispatchException: function dispatchException(exception) { if (this.done) throw exception; var context = this; function handle(loc, caught) { return record.type = "throw", record.arg = exception, context.next = loc, caught && (context.method = "next", context.arg = undefined), !!caught; } for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i], record = entry.completion; if ("root" === entry.tryLoc) return handle("end"); if (entry.tryLoc <= this.prev) { var hasCatch = hasOwn.call(entry, "catchLoc"), hasFinally = hasOwn.call(entry, "finallyLoc"); if (hasCatch && hasFinally) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } else if (hasCatch) { if (this.prev < entry.catchLoc) return handle(entry.catchLoc, !0); } else { if (!hasFinally) throw new Error("try statement without catch or finally"); if (this.prev < entry.finallyLoc) return handle(entry.finallyLoc); } } } }, abrupt: function abrupt(type, arg) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc <= this.prev && hasOwn.call(entry, "finallyLoc") && this.prev < entry.finallyLoc) { var finallyEntry = entry; break; } } finallyEntry && ("break" === type || "continue" === type) && finallyEntry.tryLoc <= arg && arg <= finallyEntry.finallyLoc && (finallyEntry = null); var record = finallyEntry ? finallyEntry.completion : {}; return record.type = type, record.arg = arg, finallyEntry ? (this.method = "next", this.next = finallyEntry.finallyLoc, ContinueSentinel) : this.complete(record); }, complete: function complete(record, afterLoc) { if ("throw" === record.type) throw record.arg; return "break" === record.type || "continue" === record.type ? this.next = record.arg : "return" === record.type ? (this.rval = this.arg = record.arg, this.method = "return", this.next = "end") : "normal" === record.type && afterLoc && (this.next = afterLoc), ContinueSentinel; }, finish: function finish(finallyLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.finallyLoc === finallyLoc) return this.complete(entry.completion, entry.afterLoc), resetTryEntry(entry), ContinueSentinel; } }, "catch": function _catch(tryLoc) { for (var i = this.tryEntries.length - 1; i >= 0; --i) { var entry = this.tryEntries[i]; if (entry.tryLoc === tryLoc) { var record = entry.completion; if ("throw" === record.type) { var thrown = record.arg; resetTryEntry(entry); } return thrown; } } throw new Error("illegal catch attempt"); }, delegateYield: function delegateYield(iterable, resultName, nextLoc) { return this.delegate = { iterator: values(iterable), resultName: resultName, nextLoc: nextLoc }, "next" === this.method && (this.arg = undefined), ContinueSentinel; } }, exports; }
|
|
31
|
+
|
|
32
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
33
|
+
|
|
34
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
35
|
+
|
|
36
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
37
|
+
|
|
38
|
+
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; }
|
|
39
|
+
|
|
40
|
+
function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
|
|
41
|
+
|
|
42
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
43
|
+
|
|
44
|
+
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); } }
|
|
45
|
+
|
|
46
|
+
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); }); }; }
|
|
47
|
+
|
|
48
|
+
var stories = {
|
|
49
|
+
title: 'Components/Suggester-workers',
|
|
50
|
+
component: _orchestrator["default"],
|
|
51
|
+
argTypes: _defaultArgTypes["default"]
|
|
52
|
+
};
|
|
53
|
+
var _default = stories;
|
|
54
|
+
exports["default"] = _default;
|
|
55
|
+
|
|
56
|
+
function fetchNaf() {
|
|
57
|
+
return fetch('/naf-rev2.json').then(function (r) {
|
|
58
|
+
return r.json();
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
function fetchFake() {
|
|
63
|
+
return fetch('/fake-nomenclature.json').then(function (r) {
|
|
64
|
+
return r.json();
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
var infoFake = {
|
|
69
|
+
name: 'fake',
|
|
70
|
+
fields: [{
|
|
71
|
+
name: 'tags',
|
|
72
|
+
rules: ['[\\w]+'],
|
|
73
|
+
language: 'French',
|
|
74
|
+
min: 3
|
|
75
|
+
}],
|
|
76
|
+
queryParser: {
|
|
77
|
+
type: 'tokenized',
|
|
78
|
+
params: {
|
|
79
|
+
language: 'French',
|
|
80
|
+
pattern: '[\\w.]+'
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
version: '1'
|
|
84
|
+
};
|
|
85
|
+
var infoNaf = {
|
|
86
|
+
name: 'naf-rev2',
|
|
87
|
+
fields: [{
|
|
88
|
+
name: 'label',
|
|
89
|
+
rules: ['[\\w]+'],
|
|
90
|
+
language: 'French',
|
|
91
|
+
min: 3
|
|
92
|
+
}, {
|
|
93
|
+
name: 'id'
|
|
94
|
+
}],
|
|
95
|
+
queryParser: {
|
|
96
|
+
type: 'tokenized',
|
|
97
|
+
params: {
|
|
98
|
+
language: 'French',
|
|
99
|
+
pattern: '[\\w.]+'
|
|
100
|
+
}
|
|
101
|
+
},
|
|
102
|
+
version: '1'
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
function loadOne(_x, _x2) {
|
|
106
|
+
return _loadOne.apply(this, arguments);
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
function _loadOne() {
|
|
110
|
+
_loadOne = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee2(info, fetchIt) {
|
|
111
|
+
var name, rubriques, db;
|
|
112
|
+
return _regeneratorRuntime().wrap(function _callee2$(_context2) {
|
|
113
|
+
while (1) {
|
|
114
|
+
switch (_context2.prev = _context2.next) {
|
|
115
|
+
case 0:
|
|
116
|
+
name = info.name;
|
|
117
|
+
_context2.next = 3;
|
|
118
|
+
return fetchIt();
|
|
119
|
+
|
|
120
|
+
case 3:
|
|
121
|
+
rubriques = _context2.sent;
|
|
122
|
+
_context2.next = 6;
|
|
123
|
+
return (0, _idbTools.openOnCreateDb)(name);
|
|
124
|
+
|
|
125
|
+
case 6:
|
|
126
|
+
db = _context2.sent;
|
|
127
|
+
_context2.next = 9;
|
|
128
|
+
return (0, _idbTools.clearDb)(db, _storeTools.CONSTANTES.STORE_DATA_NAME);
|
|
129
|
+
|
|
130
|
+
case 9:
|
|
131
|
+
_context2.next = 11;
|
|
132
|
+
return (0, _idbTools.clearDb)(db, _storeTools.CONSTANTES.STORE_INFO_NAME);
|
|
133
|
+
|
|
134
|
+
case 11:
|
|
135
|
+
_context2.next = 13;
|
|
136
|
+
return (0, _appendToIndex["default"])(info, '1', rubriques, console.log);
|
|
137
|
+
|
|
138
|
+
case 13:
|
|
139
|
+
_context2.next = 15;
|
|
140
|
+
return (0, _idbTools.insertEntity)(db, _storeTools.CONSTANTES.STORE_INFO_NAME, info);
|
|
141
|
+
|
|
142
|
+
case 15:
|
|
143
|
+
case "end":
|
|
144
|
+
return _context2.stop();
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
}, _callee2);
|
|
148
|
+
}));
|
|
149
|
+
return _loadOne.apply(this, arguments);
|
|
150
|
+
}
|
|
151
|
+
|
|
152
|
+
function Search(_ref) {
|
|
153
|
+
var storeInfo = _ref.storeInfo,
|
|
154
|
+
_ref$version = _ref.version,
|
|
155
|
+
version = _ref$version === void 0 ? '1' : _ref$version,
|
|
156
|
+
_ref$max = _ref.max,
|
|
157
|
+
max = _ref$max === void 0 ? 30 : _ref$max,
|
|
158
|
+
_ref$defaultValue = _ref.defaultValue,
|
|
159
|
+
defaultValue = _ref$defaultValue === void 0 ? '' : _ref$defaultValue;
|
|
160
|
+
var name = storeInfo.name,
|
|
161
|
+
order = storeInfo.order;
|
|
162
|
+
|
|
163
|
+
var _useState = (0, _react.useState)(defaultValue),
|
|
164
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
165
|
+
value = _useState2[0],
|
|
166
|
+
setValue = _useState2[1];
|
|
167
|
+
|
|
168
|
+
var onClick = (0, _react.useCallback)(function () {
|
|
169
|
+
function doIt() {
|
|
170
|
+
return _doIt.apply(this, arguments);
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
function _doIt() {
|
|
174
|
+
_doIt = _asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
|
|
175
|
+
var results;
|
|
176
|
+
return _regeneratorRuntime().wrap(function _callee$(_context) {
|
|
177
|
+
while (1) {
|
|
178
|
+
switch (_context.prev = _context.next) {
|
|
179
|
+
case 0:
|
|
180
|
+
_context.next = 2;
|
|
181
|
+
return (0, _searching["default"])(value, {
|
|
182
|
+
name: name,
|
|
183
|
+
version: version,
|
|
184
|
+
max: max,
|
|
185
|
+
order: order
|
|
186
|
+
});
|
|
187
|
+
|
|
188
|
+
case 2:
|
|
189
|
+
results = _context.sent;
|
|
190
|
+
console.log(results);
|
|
191
|
+
|
|
192
|
+
case 4:
|
|
193
|
+
case "end":
|
|
194
|
+
return _context.stop();
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
}, _callee);
|
|
198
|
+
}));
|
|
199
|
+
return _doIt.apply(this, arguments);
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
if (value.length) {
|
|
203
|
+
doIt();
|
|
204
|
+
}
|
|
205
|
+
}, [value, name, version, max, order]);
|
|
206
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("input", {
|
|
207
|
+
type: "search",
|
|
208
|
+
value: value,
|
|
209
|
+
onChange: function onChange(e) {
|
|
210
|
+
return setValue(e.target.value);
|
|
211
|
+
}
|
|
212
|
+
}), /*#__PURE__*/_react["default"].createElement("input", {
|
|
213
|
+
type: "button",
|
|
214
|
+
onClick: onClick,
|
|
215
|
+
value: "Search!"
|
|
216
|
+
}));
|
|
217
|
+
}
|
|
218
|
+
|
|
219
|
+
var Template = function Template(args) {
|
|
220
|
+
return /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("ul", null, /*#__PURE__*/_react["default"].createElement("li", null, /*#__PURE__*/_react["default"].createElement("input", {
|
|
221
|
+
type: "button",
|
|
222
|
+
value: "load NAF",
|
|
223
|
+
onClick: function onClick() {
|
|
224
|
+
return loadOne(infoNaf, fetchNaf);
|
|
225
|
+
}
|
|
226
|
+
}), /*#__PURE__*/_react["default"].createElement(Search, {
|
|
227
|
+
storeInfo: infoNaf,
|
|
228
|
+
defaultValue: "culture du tabac"
|
|
229
|
+
})), /*#__PURE__*/_react["default"].createElement("li", null, /*#__PURE__*/_react["default"].createElement("input", {
|
|
230
|
+
type: "button",
|
|
231
|
+
value: "load FAKE",
|
|
232
|
+
onClick: function onClick() {
|
|
233
|
+
return loadOne(infoFake, fetchFake);
|
|
234
|
+
}
|
|
235
|
+
}), /*#__PURE__*/_react["default"].createElement(Search, {
|
|
236
|
+
storeInfo: infoFake,
|
|
237
|
+
defaultValue: "madame"
|
|
238
|
+
}))));
|
|
239
|
+
};
|
|
240
|
+
|
|
241
|
+
var Default = Template.bind({});
|
|
242
|
+
exports.Default = Default;
|
|
@@ -43,7 +43,13 @@ function createFilterTokens(fields, stopWords) {
|
|
|
43
43
|
var tokenizeIt = FIELDS_TOKENIZER_MAP[name];
|
|
44
44
|
|
|
45
45
|
if (name in entity) {
|
|
46
|
-
|
|
46
|
+
var value = entity[name];
|
|
47
|
+
|
|
48
|
+
if (value === undefined || value === null) {
|
|
49
|
+
return [];
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
return tokenizeIt("".concat(value));
|
|
47
53
|
}
|
|
48
54
|
|
|
49
55
|
return [];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inseefr/lunatic",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.3-v2",
|
|
4
4
|
"workersVersion": "0.2.4-experimental",
|
|
5
5
|
"description": "Library of questionnaire components",
|
|
6
6
|
"repository": {
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"build-searching-worker": "webpack --config ./webpack-searching-worker.config.js",
|
|
39
39
|
"build-label-worker": "webpack --config ./webpack-label-worker.config.js",
|
|
40
40
|
"build-workers": "yarn build-append-worker && yarn build-searching-worker && yarn build-label-worker",
|
|
41
|
-
"storybook": "start-storybook -p 9999",
|
|
41
|
+
"storybook": "start-storybook -p 9999 -s ./public",
|
|
42
42
|
"build-storybook": "build-storybook"
|
|
43
43
|
},
|
|
44
44
|
"keywords": [
|
|
@@ -82,6 +82,7 @@
|
|
|
82
82
|
"@emotion/react": "^11.9.3",
|
|
83
83
|
"@emotion/styled": "^11.9.3",
|
|
84
84
|
"@mui/material": "^5.8.6",
|
|
85
|
+
"@storybook/addon-a11y": "^6.5.12",
|
|
85
86
|
"@storybook/addon-actions": "^6.5.8",
|
|
86
87
|
"@storybook/addon-essentials": "^6.5.8",
|
|
87
88
|
"@storybook/addon-interactions": "^6.5.8",
|