@inseefr/lunatic 2.6.14 → 2.6.16
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/lunatic-components.js +24 -11
- package/lib/components/modal/lunatic-modal.js +4 -2
- package/lib/components/suggester/html/suggester.js +10 -4
- package/lib/components/suggester/idb-suggester/check-store.js +1 -1
- package/lib/components/suggester/idb-suggester/idb-suggester.js +6 -2
- package/lib/components/suggester/lunatic-suggester.js +6 -3
- package/lib/src/components/modal/html/modal.d.ts +1 -1
- package/lib/src/components/suggester/html/suggester.d.ts +2 -0
- package/lib/src/components/suggester/idb-suggester/idb-suggester.d.ts +2 -2
- package/lib/src/components/suggester/lunatic-suggester.d.ts +1 -1
- package/lib/src/components/type.d.ts +2 -0
- package/lib/use-lunatic/use-suggesters.js +21 -13
- package/package.json +2 -2
|
@@ -16,27 +16,40 @@ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t =
|
|
|
16
16
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
17
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
18
18
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
19
|
+
var LunaticComponentsConatainer = /*#__PURE__*/(0, _react.forwardRef)(function Container(_ref, ref) {
|
|
20
|
+
var children = _ref.children,
|
|
21
|
+
autoFocusKey = _ref.autoFocusKey;
|
|
22
|
+
if (autoFocusKey) {
|
|
23
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
24
|
+
ref: ref,
|
|
25
|
+
children: children
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_jsxRuntime.Fragment, {
|
|
29
|
+
children: children
|
|
30
|
+
});
|
|
31
|
+
});
|
|
19
32
|
/**
|
|
20
33
|
* Entry point for orchestrators, this component display the list of fields
|
|
21
34
|
*/
|
|
22
|
-
function LunaticComponents(
|
|
23
|
-
var components =
|
|
24
|
-
autoFocusKey =
|
|
25
|
-
componentProps =
|
|
26
|
-
|
|
27
|
-
wrapper =
|
|
28
|
-
var children =
|
|
35
|
+
function LunaticComponents(_ref2) {
|
|
36
|
+
var components = _ref2.components,
|
|
37
|
+
autoFocusKey = _ref2.autoFocusKey,
|
|
38
|
+
componentProps = _ref2.componentProps,
|
|
39
|
+
_ref2$wrapper = _ref2.wrapper,
|
|
40
|
+
wrapper = _ref2$wrapper === void 0 ? function (_ref3) {
|
|
41
|
+
var children = _ref3.children;
|
|
29
42
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)("div", {
|
|
30
43
|
className: "lunatic lunatic-component",
|
|
31
44
|
children: children
|
|
32
45
|
});
|
|
33
|
-
} :
|
|
46
|
+
} : _ref2$wrapper;
|
|
34
47
|
var wrapperRef = (0, _react.useRef)(null);
|
|
35
48
|
var hasComponents = components.length > 0;
|
|
36
|
-
var WrapperComponent = autoFocusKey ? 'div' : _react.Fragment;
|
|
37
49
|
(0, _useAutoFocus.useAutoFocus)(wrapperRef, hasComponents ? autoFocusKey : undefined);
|
|
38
|
-
return /*#__PURE__*/(0, _jsxRuntime.jsx)(
|
|
39
|
-
ref:
|
|
50
|
+
return /*#__PURE__*/(0, _jsxRuntime.jsx)(LunaticComponentsConatainer, {
|
|
51
|
+
ref: wrapperRef,
|
|
52
|
+
autoFocusKey: autoFocusKey,
|
|
40
53
|
children: components.map(function (component, k) {
|
|
41
54
|
var props = _objectSpread(_objectSpread({}, component), componentProps === null || componentProps === void 0 ? void 0 : componentProps(component));
|
|
42
55
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_react.Fragment, {
|
|
@@ -16,7 +16,8 @@ function LunaticModal(props) {
|
|
|
16
16
|
label = props.label,
|
|
17
17
|
description = props.description,
|
|
18
18
|
goNextPage = props.goNextPage,
|
|
19
|
-
goPreviousPage = props.goPreviousPage
|
|
19
|
+
goPreviousPage = props.goPreviousPage,
|
|
20
|
+
backPage = props.backPage;
|
|
20
21
|
var dialogRef = (0, _react.useRef)(null);
|
|
21
22
|
(0, _react.useEffect)(function () {
|
|
22
23
|
var _dialogRef$current;
|
|
@@ -54,7 +55,8 @@ function LunaticModal(props) {
|
|
|
54
55
|
onClick: handleDialogClick,
|
|
55
56
|
id: id,
|
|
56
57
|
label: label,
|
|
57
|
-
description: description
|
|
58
|
+
description: description,
|
|
59
|
+
backPage: backPage
|
|
58
60
|
})
|
|
59
61
|
});
|
|
60
62
|
}
|
|
@@ -38,7 +38,10 @@ function Suggester(_ref) {
|
|
|
38
38
|
searching = _ref.searching,
|
|
39
39
|
label = _ref.label,
|
|
40
40
|
description = _ref.description,
|
|
41
|
-
errors = _ref.errors
|
|
41
|
+
errors = _ref.errors,
|
|
42
|
+
_ref$arbitrary = _ref.arbitrary,
|
|
43
|
+
arbitrary = _ref$arbitrary === void 0 ? true : _ref$arbitrary,
|
|
44
|
+
focused = _ref.focused;
|
|
42
45
|
var _useState = (0, _react.useState)(''),
|
|
43
46
|
_useState2 = _slicedToArray(_useState, 2),
|
|
44
47
|
search = _useState2[0],
|
|
@@ -72,7 +75,9 @@ function Suggester(_ref) {
|
|
|
72
75
|
setOptions(results);
|
|
73
76
|
setSearch(search);
|
|
74
77
|
// if a user does not select an option in the list, their search term is saved
|
|
75
|
-
|
|
78
|
+
if (arbitrary) {
|
|
79
|
+
onSelect(search);
|
|
80
|
+
}
|
|
76
81
|
}
|
|
77
82
|
_context.next = 13;
|
|
78
83
|
break;
|
|
@@ -89,7 +94,7 @@ function Suggester(_ref) {
|
|
|
89
94
|
return function (_x) {
|
|
90
95
|
return _ref2.apply(this, arguments);
|
|
91
96
|
};
|
|
92
|
-
}(), [searching, onSelect]);
|
|
97
|
+
}(), [searching, arbitrary, onSelect]);
|
|
93
98
|
var defaultSearch = getSearch(search, value);
|
|
94
99
|
return /*#__PURE__*/(0, _jsxRuntime.jsx)(_commons.ComboBox, {
|
|
95
100
|
id: id,
|
|
@@ -108,7 +113,8 @@ function Suggester(_ref) {
|
|
|
108
113
|
placeholder: placeholder,
|
|
109
114
|
label: label,
|
|
110
115
|
description: description,
|
|
111
|
-
errors: errors
|
|
116
|
+
errors: errors,
|
|
117
|
+
focused: focused
|
|
112
118
|
});
|
|
113
119
|
}
|
|
114
120
|
function getSearch(search, value) {
|
|
@@ -91,7 +91,7 @@ function CheckStore(_ref) {
|
|
|
91
91
|
if (ready === 0) {
|
|
92
92
|
return /*#__PURE__*/(0, _jsxRuntime.jsxs)("div", {
|
|
93
93
|
className: "lunatic-suggester-in-progress",
|
|
94
|
-
children: ["
|
|
94
|
+
children: ["La liste ", storeName, " est en cours de chargement."]
|
|
95
95
|
});
|
|
96
96
|
}
|
|
97
97
|
if (ready === 200) {
|
|
@@ -33,7 +33,9 @@ function IDBSuggester(_ref) {
|
|
|
33
33
|
getSuggesterStatus = _ref.getSuggesterStatus,
|
|
34
34
|
errors = _ref.errors,
|
|
35
35
|
readOnly = _ref.readOnly,
|
|
36
|
-
workersBasePath = _ref.workersBasePath
|
|
36
|
+
workersBasePath = _ref.workersBasePath,
|
|
37
|
+
arbitrary = _ref.arbitrary,
|
|
38
|
+
focused = _ref.focused;
|
|
37
39
|
var _useState = (0, _react.useState)(undefined),
|
|
38
40
|
_useState2 = _slicedToArray(_useState, 2),
|
|
39
41
|
store = _useState2[0],
|
|
@@ -65,7 +67,9 @@ function IDBSuggester(_ref) {
|
|
|
65
67
|
value: value,
|
|
66
68
|
label: label,
|
|
67
69
|
description: description,
|
|
68
|
-
errors: errors
|
|
70
|
+
errors: errors,
|
|
71
|
+
arbitrary: arbitrary,
|
|
72
|
+
focused: focused
|
|
69
73
|
})
|
|
70
74
|
})
|
|
71
75
|
});
|
|
@@ -16,7 +16,6 @@ function LunaticSuggester(_ref) {
|
|
|
16
16
|
optionRenderer = _ref.optionRenderer,
|
|
17
17
|
labelRenderer = _ref.labelRenderer,
|
|
18
18
|
idbVersion = _ref.idbVersion,
|
|
19
|
-
focused = _ref.focused,
|
|
20
19
|
value = _ref.value,
|
|
21
20
|
handleChange = _ref.handleChange,
|
|
22
21
|
disabled = _ref.disabled,
|
|
@@ -32,7 +31,9 @@ function LunaticSuggester(_ref) {
|
|
|
32
31
|
response = _ref.response,
|
|
33
32
|
className = _ref.className,
|
|
34
33
|
getSuggesterStatus = _ref.getSuggesterStatus,
|
|
35
|
-
workersBasePath = _ref.workersBasePath
|
|
34
|
+
workersBasePath = _ref.workersBasePath,
|
|
35
|
+
arbitrary = _ref.arbitrary,
|
|
36
|
+
focused = _ref.focused;
|
|
36
37
|
var onChange = (0, _useOnHandleChange["default"])({
|
|
37
38
|
handleChange: handleChange,
|
|
38
39
|
response: response,
|
|
@@ -62,7 +63,9 @@ function LunaticSuggester(_ref) {
|
|
|
62
63
|
getSuggesterStatus: getSuggesterStatus,
|
|
63
64
|
className: className,
|
|
64
65
|
readOnly: readOnly,
|
|
65
|
-
workersBasePath: workersBasePath
|
|
66
|
+
workersBasePath: workersBasePath,
|
|
67
|
+
arbitrary: arbitrary,
|
|
68
|
+
focused: focused
|
|
66
69
|
})
|
|
67
70
|
});
|
|
68
71
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { MouseEventHandler, ReactEventHandler, RefObject } from 'react';
|
|
2
2
|
import type { LunaticComponentProps } from '../../type';
|
|
3
3
|
import './modal.scss';
|
|
4
|
-
type Props = Pick<LunaticComponentProps<'ConfirmationModal'>, 'id' | 'label' | 'description'> & {
|
|
4
|
+
type Props = Pick<LunaticComponentProps<'ConfirmationModal'>, 'id' | 'label' | 'description' | 'backPage'> & {
|
|
5
5
|
onClose: ReactEventHandler<HTMLDialogElement>;
|
|
6
6
|
onCancel: ReactEventHandler<HTMLDialogElement>;
|
|
7
7
|
onClick: MouseEventHandler<HTMLDialogElement>;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import type { LunaticError } from '../../../use-lunatic/type';
|
|
2
2
|
import type { LunaticComponentProps } from '../../type';
|
|
3
|
-
type Props = Pick<LunaticComponentProps<'Suggester'>, 'storeName' | 'idbVersion' | 'id' | 'className' | 'optionRenderer' | 'labelRenderer' | 'disabled' | 'readOnly' | 'value' | 'label' | 'description' | 'getSuggesterStatus'> & {
|
|
3
|
+
type Props = Pick<LunaticComponentProps<'Suggester'>, 'storeName' | 'idbVersion' | 'id' | 'className' | 'optionRenderer' | 'labelRenderer' | 'disabled' | 'readOnly' | 'value' | 'label' | 'description' | 'getSuggesterStatus' | 'arbitrary' | 'focused'> & {
|
|
4
4
|
errors?: LunaticError[];
|
|
5
5
|
onSelect: (v: string | null) => void;
|
|
6
6
|
workersBasePath?: string;
|
|
7
7
|
};
|
|
8
|
-
export declare function IDBSuggester({ storeName, idbVersion, id, className, optionRenderer, labelRenderer, onSelect, disabled, value, label, description, getSuggesterStatus, errors, readOnly, workersBasePath, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
export declare function IDBSuggester({ storeName, idbVersion, id, className, optionRenderer, labelRenderer, onSelect, disabled, value, label, description, getSuggesterStatus, errors, readOnly, workersBasePath, arbitrary, focused, }: Props): import("react/jsx-runtime").JSX.Element;
|
|
9
9
|
export {};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { LunaticComponentProps } from '../type';
|
|
2
|
-
declare function LunaticSuggester({ id, storeName, optionRenderer, labelRenderer, idbVersion,
|
|
2
|
+
declare function LunaticSuggester({ id, storeName, optionRenderer, labelRenderer, idbVersion, value, handleChange, disabled, readOnly, errors, label, description, preferences, declarations, missing, missingResponse, management, response, className, getSuggesterStatus, workersBasePath, arbitrary, focused, }: LunaticComponentProps<'Suggester'>): import("react/jsx-runtime").JSX.Element;
|
|
3
3
|
export default LunaticSuggester;
|
|
@@ -257,6 +257,7 @@ type ComponentPropsByType = {
|
|
|
257
257
|
response: {
|
|
258
258
|
name: string;
|
|
259
259
|
};
|
|
260
|
+
arbitrary?: boolean;
|
|
260
261
|
};
|
|
261
262
|
Summary: LunaticBaseProps<string | null> & {
|
|
262
263
|
sections: Array<{
|
|
@@ -275,6 +276,7 @@ type ComponentPropsByType = {
|
|
|
275
276
|
page: string;
|
|
276
277
|
goNextPage: () => void;
|
|
277
278
|
goPreviousPage: () => void;
|
|
279
|
+
backPage?: string;
|
|
278
280
|
};
|
|
279
281
|
RemoteComponent: LunaticBaseProps<string | null> & {
|
|
280
282
|
components: LunaticComponentDefinition[];
|
|
@@ -114,19 +114,27 @@ function useSuggesters(_ref) {
|
|
|
114
114
|
setTimestamp(Date.now());
|
|
115
115
|
}
|
|
116
116
|
case 10:
|
|
117
|
+
_context.next = 15;
|
|
118
|
+
break;
|
|
119
|
+
case 12:
|
|
120
|
+
_context.prev = 12;
|
|
121
|
+
_context.t0 = _context["catch"](4);
|
|
122
|
+
console.warn("Error during suggester's cleaning ".concat(name), _context.t0);
|
|
123
|
+
case 15:
|
|
124
|
+
_context.prev = 15;
|
|
117
125
|
if (!(current[name] === SuggesterStatus.pending)) {
|
|
118
|
-
_context.next =
|
|
126
|
+
_context.next = 26;
|
|
119
127
|
break;
|
|
120
128
|
}
|
|
121
|
-
_context.next =
|
|
129
|
+
_context.next = 19;
|
|
122
130
|
return getReferentiel(name);
|
|
123
|
-
case
|
|
131
|
+
case 19:
|
|
124
132
|
data = _context.sent;
|
|
125
133
|
_createAppendTask = (0, _createAppendTask3.createAppendTask)(store, 1, nothing, workersBasePath), _createAppendTask2 = _slicedToArray(_createAppendTask, 2), append = _createAppendTask2[0], abort = _createAppendTask2[1];
|
|
126
134
|
aborts.current.push(abort);
|
|
127
|
-
_context.next =
|
|
135
|
+
_context.next = 24;
|
|
128
136
|
return append(data);
|
|
129
|
-
case
|
|
137
|
+
case 24:
|
|
130
138
|
result = _context.sent;
|
|
131
139
|
if (result) {
|
|
132
140
|
setStatus(status, name, SuggesterStatus.success);
|
|
@@ -135,20 +143,20 @@ function useSuggesters(_ref) {
|
|
|
135
143
|
setStatus(status, name, SuggesterStatus.error);
|
|
136
144
|
setTimestamp(Date.now());
|
|
137
145
|
}
|
|
138
|
-
case
|
|
139
|
-
_context.next =
|
|
146
|
+
case 26:
|
|
147
|
+
_context.next = 33;
|
|
140
148
|
break;
|
|
141
|
-
case
|
|
142
|
-
_context.prev =
|
|
143
|
-
_context.
|
|
144
|
-
console.error(_context.
|
|
149
|
+
case 28:
|
|
150
|
+
_context.prev = 28;
|
|
151
|
+
_context.t1 = _context["catch"](15);
|
|
152
|
+
console.error("Error during suggester's loading ".concat(name), _context.t1);
|
|
145
153
|
setStatus(status, name, SuggesterStatus.error);
|
|
146
154
|
setTimestamp(Date.now());
|
|
147
|
-
case
|
|
155
|
+
case 33:
|
|
148
156
|
case "end":
|
|
149
157
|
return _context.stop();
|
|
150
158
|
}
|
|
151
|
-
}, _callee, null, [[4,
|
|
159
|
+
}, _callee, null, [[4, 12], [15, 28]]);
|
|
152
160
|
}));
|
|
153
161
|
return function (_x) {
|
|
154
162
|
return _ref3.apply(this, arguments);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@inseefr/lunatic",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.16",
|
|
4
4
|
"workersVersion": "0.3.0-experimental",
|
|
5
5
|
"description": "Library of questionnaire components",
|
|
6
6
|
"repository": {
|
|
@@ -133,7 +133,7 @@
|
|
|
133
133
|
"damerau-levenshtein": "^1.0.7",
|
|
134
134
|
"eslint": "7.30.0",
|
|
135
135
|
"eslint-config-prettier": "^9.0.0",
|
|
136
|
-
"eslint-config-react-app": "^
|
|
136
|
+
"eslint-config-react-app": "^7.0.0",
|
|
137
137
|
"eslint-plugin-flowtype": "^8.0.0",
|
|
138
138
|
"eslint-plugin-import": "^2.19.1",
|
|
139
139
|
"eslint-plugin-jsx-a11y": "^6.1.1",
|