arengibook 2.4.695 → 2.4.696
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/dist/index.js +43 -10
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -41780,10 +41780,8 @@ var ChipsAutoComplete = function ChipsAutoComplete(_ref) {
|
|
|
41780
41780
|
_ref$minLength = _ref.minLength,
|
|
41781
41781
|
minLength = _ref$minLength === void 0 ? 1 : _ref$minLength,
|
|
41782
41782
|
_ref$delay = _ref.delay,
|
|
41783
|
-
delay = _ref$delay === void 0 ? 300 : _ref$delay
|
|
41784
|
-
|
|
41785
|
-
* Suggestions internes (storybook / async fake)
|
|
41786
|
-
*/
|
|
41783
|
+
delay = _ref$delay === void 0 ? 300 : _ref$delay,
|
|
41784
|
+
optionsUrl = _ref.optionsUrl;
|
|
41787
41785
|
var _useState = useState([]),
|
|
41788
41786
|
_useState2 = _slicedToArray$a(_useState, 2),
|
|
41789
41787
|
internalSuggestions = _useState2[0],
|
|
@@ -41797,10 +41795,6 @@ var ChipsAutoComplete = function ChipsAutoComplete(_ref) {
|
|
|
41797
41795
|
};
|
|
41798
41796
|
}, []);
|
|
41799
41797
|
var resolvedSuggestions = Array.isArray(suggestions) && suggestions.length > 0 ? suggestions : internalSuggestions;
|
|
41800
|
-
|
|
41801
|
-
/**
|
|
41802
|
-
* Value interne (TOUJOURS un tableau)
|
|
41803
|
-
*/
|
|
41804
41798
|
var _useState3 = useState([]),
|
|
41805
41799
|
_useState4 = _slicedToArray$a(_useState3, 2),
|
|
41806
41800
|
internalValue = _useState4[0],
|
|
@@ -41813,9 +41807,47 @@ var ChipsAutoComplete = function ChipsAutoComplete(_ref) {
|
|
|
41813
41807
|
onChange(e);
|
|
41814
41808
|
}
|
|
41815
41809
|
};
|
|
41810
|
+
var fetchSuggestions = /*#__PURE__*/function () {
|
|
41811
|
+
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(event) {
|
|
41812
|
+
var query, url, response, results, _t;
|
|
41813
|
+
return _regenerator().w(function (_context) {
|
|
41814
|
+
while (1) switch (_context.n) {
|
|
41815
|
+
case 0:
|
|
41816
|
+
query = (event.query || '').toLowerCase();
|
|
41817
|
+
url = new URL(optionsUrl);
|
|
41818
|
+
url.searchParams.append('query', query);
|
|
41819
|
+
_context.p = 1;
|
|
41820
|
+
_context.n = 2;
|
|
41821
|
+
return fetch(url);
|
|
41822
|
+
case 2:
|
|
41823
|
+
response = _context.v;
|
|
41824
|
+
_context.n = 3;
|
|
41825
|
+
return response.json();
|
|
41826
|
+
case 3:
|
|
41827
|
+
results = _context.v;
|
|
41828
|
+
if (typeof window.setChipsSuggestions === 'function') {
|
|
41829
|
+
window.setChipsSuggestions(results);
|
|
41830
|
+
}
|
|
41831
|
+
_context.n = 5;
|
|
41832
|
+
break;
|
|
41833
|
+
case 4:
|
|
41834
|
+
_context.p = 4;
|
|
41835
|
+
_t = _context.v;
|
|
41836
|
+
console.error('Erreur lors de la récupération des suggestions :', _t);
|
|
41837
|
+
case 5:
|
|
41838
|
+
return _context.a(2);
|
|
41839
|
+
}
|
|
41840
|
+
}, _callee, null, [[1, 4]]);
|
|
41841
|
+
}));
|
|
41842
|
+
return function fetchSuggestions(_x) {
|
|
41843
|
+
return _ref2.apply(this, arguments);
|
|
41844
|
+
};
|
|
41845
|
+
}();
|
|
41816
41846
|
var handleComplete = function handleComplete(event) {
|
|
41817
|
-
if (
|
|
41818
|
-
|
|
41847
|
+
if (optionsUrl) {
|
|
41848
|
+
fetchSuggestions(event); // Utilise la fonction asynchrone si une URL est fournie
|
|
41849
|
+
} else if (typeof completeMethod === 'function') {
|
|
41850
|
+
completeMethod(event); // Sinon, utilise la méthode fournie (comme searchSync)
|
|
41819
41851
|
}
|
|
41820
41852
|
};
|
|
41821
41853
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
@@ -41914,6 +41946,7 @@ var ChipsAutoCompletePresets = {
|
|
|
41914
41946
|
Default: {
|
|
41915
41947
|
suggestions: [],
|
|
41916
41948
|
field: 'label',
|
|
41949
|
+
optionsUrl: null,
|
|
41917
41950
|
completeMethod: searchSync
|
|
41918
41951
|
},
|
|
41919
41952
|
Disabled: {
|