arengibook 2.4.592 → 2.4.593
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 +55 -29
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -36010,28 +36010,28 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36010
36010
|
loadedOptions = _useState6[0],
|
|
36011
36011
|
setLoadedOptions = _useState6[1];
|
|
36012
36012
|
var isOptionLoadFunction = typeof options === 'function';
|
|
36013
|
+
var _useState7 = useState(''),
|
|
36014
|
+
_useState8 = _slicedToArray$8(_useState7, 2);
|
|
36015
|
+
_useState8[0];
|
|
36016
|
+
_useState8[1];
|
|
36017
|
+
var filterRef = useRef('');
|
|
36018
|
+
useEffect(function () {
|
|
36019
|
+
var handleScroll = function handleScroll(e) {
|
|
36020
|
+
var target = e.target;
|
|
36013
36021
|
|
|
36014
|
-
|
|
36015
|
-
|
|
36016
|
-
|
|
36017
|
-
|
|
36018
|
-
// try {
|
|
36019
|
-
// const result = await options();
|
|
36020
|
-
// setLoadedOptions(result);
|
|
36021
|
-
// } catch (err) {
|
|
36022
|
-
// console.error('Erreur lors du chargement des options:', err);
|
|
36023
|
-
// } finally {
|
|
36024
|
-
// setLoading(false);
|
|
36025
|
-
// }
|
|
36026
|
-
// };
|
|
36027
|
-
//
|
|
36028
|
-
// loadOptions();
|
|
36029
|
-
// } else {
|
|
36030
|
-
// setLoadedOptions(options);
|
|
36031
|
-
// }
|
|
36032
|
-
// }, [options, isOptionLoadFunction]);
|
|
36022
|
+
// Si on scroll dans la liste elle-même (aucun effet de suppression de liste)
|
|
36023
|
+
if (target.closest && target.closest('.p-dropdown-panel')) {
|
|
36024
|
+
return;
|
|
36025
|
+
}
|
|
36033
36026
|
|
|
36034
|
-
|
|
36027
|
+
// Sinon, on ferme la zone de liste
|
|
36028
|
+
var dropdownPanels = document.querySelectorAll('.p-dropdown-panel');
|
|
36029
|
+
dropdownPanels.forEach(function (panel) {
|
|
36030
|
+
if (panel && panel.style.display !== 'none') {
|
|
36031
|
+
document.body.click(); // Déclenche un "click outside"
|
|
36032
|
+
}
|
|
36033
|
+
});
|
|
36034
|
+
};
|
|
36035
36035
|
var loadOptions = /*#__PURE__*/function () {
|
|
36036
36036
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
36037
36037
|
var result, _t;
|
|
@@ -36074,6 +36074,10 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36074
36074
|
};
|
|
36075
36075
|
}();
|
|
36076
36076
|
loadOptions();
|
|
36077
|
+
window.addEventListener('scroll', handleScroll, true);
|
|
36078
|
+
return function () {
|
|
36079
|
+
window.removeEventListener('scroll', handleScroll, true);
|
|
36080
|
+
};
|
|
36077
36081
|
}, [options, isOptionLoadFunction]);
|
|
36078
36082
|
useEffect(function () {
|
|
36079
36083
|
setOptionSelected(value !== null && value !== void 0 ? value : null);
|
|
@@ -36106,7 +36110,8 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36106
36110
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
36107
36111
|
className: "flex align-items-center",
|
|
36108
36112
|
style: {
|
|
36109
|
-
|
|
36113
|
+
padding: '6px 10px',
|
|
36114
|
+
height: 'auto'
|
|
36110
36115
|
}
|
|
36111
36116
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
36112
36117
|
style: _objectSpread2({
|
|
@@ -36123,6 +36128,8 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36123
36128
|
}, option === null || option === void 0 ? void 0 : option[optionLabel])));
|
|
36124
36129
|
}
|
|
36125
36130
|
};
|
|
36131
|
+
({
|
|
36132
|
+
maxHeight: loadedOptions.length <= 6 ? "".concat(loadedOptions.length * 42, "px") : '240px'});
|
|
36126
36133
|
var valueTemplate = function valueTemplate(option) {
|
|
36127
36134
|
if (isSelectMeta) {
|
|
36128
36135
|
var iconColor = option !== null && option !== void 0 && option.color ? inverseColor(option === null || option === void 0 ? void 0 : option.color) : '#FFFFFF';
|
|
@@ -36155,7 +36162,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36155
36162
|
var onLazyLoad = /*#__PURE__*/function () {
|
|
36156
36163
|
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(event) {
|
|
36157
36164
|
var _event$filter;
|
|
36158
|
-
var search, _res$options, _res$additional$page, _res$additional, res, newOptions, _t2;
|
|
36165
|
+
var search, currentPage, _res$options, _res$additional$page, _res$additional, res, newOptions, _t2;
|
|
36159
36166
|
return _regenerator().w(function (_context2) {
|
|
36160
36167
|
while (1) switch (_context2.n) {
|
|
36161
36168
|
case 0:
|
|
@@ -36165,20 +36172,21 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36165
36172
|
}
|
|
36166
36173
|
return _context2.a(2);
|
|
36167
36174
|
case 1:
|
|
36175
|
+
search = (_event$filter = event === null || event === void 0 ? void 0 : event.filter) !== null && _event$filter !== void 0 ? _event$filter : filterRef.current;
|
|
36176
|
+
currentPage = currentPageRef.current;
|
|
36168
36177
|
setLoading(true);
|
|
36169
|
-
search = (_event$filter = event === null || event === void 0 ? void 0 : event.filter) !== null && _event$filter !== void 0 ? _event$filter : '';
|
|
36170
36178
|
_context2.p = 2;
|
|
36171
36179
|
_context2.n = 3;
|
|
36172
36180
|
return options(search, loadedOptions, {
|
|
36173
|
-
page:
|
|
36181
|
+
page: currentPage
|
|
36174
36182
|
});
|
|
36175
36183
|
case 3:
|
|
36176
36184
|
res = _context2.v;
|
|
36177
36185
|
newOptions = (_res$options = res === null || res === void 0 ? void 0 : res.options) !== null && _res$options !== void 0 ? _res$options : [];
|
|
36178
36186
|
setLoadedOptions(function (prevOptions) {
|
|
36179
|
-
return [].concat(_toConsumableArray$6(prevOptions), _toConsumableArray$6(newOptions));
|
|
36187
|
+
return currentPage === 1 ? newOptions : [].concat(_toConsumableArray$6(prevOptions), _toConsumableArray$6(newOptions));
|
|
36180
36188
|
});
|
|
36181
|
-
currentPageRef.current = (_res$additional$page = res === null || res === void 0 || (_res$additional = res.additional) === null || _res$additional === void 0 ? void 0 : _res$additional.page) !== null && _res$additional$page !== void 0 ? _res$additional$page :
|
|
36189
|
+
currentPageRef.current = (_res$additional$page = res === null || res === void 0 || (_res$additional = res.additional) === null || _res$additional === void 0 ? void 0 : _res$additional.page) !== null && _res$additional$page !== void 0 ? _res$additional$page : currentPage + 1;
|
|
36182
36190
|
_context2.n = 5;
|
|
36183
36191
|
break;
|
|
36184
36192
|
case 4:
|
|
@@ -36198,6 +36206,18 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36198
36206
|
return _ref4.apply(this, arguments);
|
|
36199
36207
|
};
|
|
36200
36208
|
}();
|
|
36209
|
+
var handleFilter = function handleFilter(event) {
|
|
36210
|
+
var _event$value;
|
|
36211
|
+
var value = (_event$value = event === null || event === void 0 ? void 0 : event.value) !== null && _event$value !== void 0 ? _event$value : '';
|
|
36212
|
+
filterRef.current = value;
|
|
36213
|
+
currentPageRef.current = 1;
|
|
36214
|
+
setLoadedOptions([]);
|
|
36215
|
+
if (isOptionLoadFunction) {
|
|
36216
|
+
onLazyLoad({
|
|
36217
|
+
filter: value
|
|
36218
|
+
});
|
|
36219
|
+
}
|
|
36220
|
+
};
|
|
36201
36221
|
var handleChange = function handleChange(e) {
|
|
36202
36222
|
var newValue = e.value;
|
|
36203
36223
|
setOptionSelected(newValue);
|
|
@@ -36269,9 +36289,14 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36269
36289
|
placeholder: placeholder,
|
|
36270
36290
|
disabled: disabled,
|
|
36271
36291
|
filter: filter,
|
|
36292
|
+
onFilter: handleFilter,
|
|
36272
36293
|
optionLabel: optionLabel,
|
|
36273
36294
|
optionValue: optionValue,
|
|
36274
36295
|
style: style,
|
|
36296
|
+
panelStyle: {
|
|
36297
|
+
maxHeight: 'auto',
|
|
36298
|
+
overflowY: 'auto'
|
|
36299
|
+
},
|
|
36275
36300
|
itemTemplate: optionTemplate,
|
|
36276
36301
|
valueTemplate: valueTemplate,
|
|
36277
36302
|
showClear: showClear,
|
|
@@ -36478,6 +36503,7 @@ var DropdownPresets = {
|
|
|
36478
36503
|
generalIcon: 'pi pi-circle-fill'
|
|
36479
36504
|
},
|
|
36480
36505
|
isSelectMeta: true,
|
|
36506
|
+
showClear: true,
|
|
36481
36507
|
valueStyle: {
|
|
36482
36508
|
fontSize: '14px',
|
|
36483
36509
|
fontFamily: 'Arial'
|
|
@@ -36501,8 +36527,7 @@ var DropdownPresets = {
|
|
|
36501
36527
|
_context2.n = 1;
|
|
36502
36528
|
return simulateNetworkDelay();
|
|
36503
36529
|
case 1:
|
|
36504
|
-
|
|
36505
|
-
allOptions = generateOptions(100); // Filtrer les options en fonction de la recherche
|
|
36530
|
+
allOptions = generateOptions(100);
|
|
36506
36531
|
filteredOptions = allOptions.filter(function (opt) {
|
|
36507
36532
|
return opt.nom.toLowerCase().includes(search.toLowerCase());
|
|
36508
36533
|
}); // Pagination des résultats filtrés
|
|
@@ -36540,7 +36565,8 @@ var DropdownPresets = {
|
|
|
36540
36565
|
optionStyle: {
|
|
36541
36566
|
fontSize: '14px',
|
|
36542
36567
|
fontFamily: 'Arial'
|
|
36543
|
-
}
|
|
36568
|
+
},
|
|
36569
|
+
showClear: true
|
|
36544
36570
|
},
|
|
36545
36571
|
Group: {
|
|
36546
36572
|
placeholder: 'Veuillez choisir une option',
|