arengibook 2.4.592 → 2.4.594
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 -35
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -35946,7 +35946,8 @@ var PopupPresets = {
|
|
|
35946
35946
|
};
|
|
35947
35947
|
|
|
35948
35948
|
var Dropdown = function Dropdown(_ref) {
|
|
35949
|
-
var
|
|
35949
|
+
var ref = _ref.ref,
|
|
35950
|
+
_ref$options = _ref.options,
|
|
35950
35951
|
options = _ref$options === void 0 ? [] : _ref$options,
|
|
35951
35952
|
_ref$isGroupedOption = _ref.isGroupedOption,
|
|
35952
35953
|
isGroupedOption = _ref$isGroupedOption === void 0 ? false : _ref$isGroupedOption,
|
|
@@ -35998,40 +35999,34 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
35998
35999
|
_useState2 = _slicedToArray$8(_useState, 2),
|
|
35999
36000
|
optionSelected = _useState2[0],
|
|
36000
36001
|
setOptionSelected = _useState2[1];
|
|
36001
|
-
useRef([]);
|
|
36002
36002
|
var _useState3 = useState(false),
|
|
36003
36003
|
_useState4 = _slicedToArray$8(_useState3, 2),
|
|
36004
36004
|
loading = _useState4[0],
|
|
36005
36005
|
setLoading = _useState4[1];
|
|
36006
|
-
useRef([]);
|
|
36007
36006
|
var currentPageRef = useRef(1);
|
|
36008
36007
|
var _useState5 = useState([]),
|
|
36009
36008
|
_useState6 = _slicedToArray$8(_useState5, 2),
|
|
36010
36009
|
loadedOptions = _useState6[0],
|
|
36011
36010
|
setLoadedOptions = _useState6[1];
|
|
36012
36011
|
var isOptionLoadFunction = typeof options === 'function';
|
|
36012
|
+
var filterRef = useRef('');
|
|
36013
|
+
useEffect(function () {
|
|
36014
|
+
var handleScroll = function handleScroll(e) {
|
|
36015
|
+
var target = e.target;
|
|
36013
36016
|
|
|
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]);
|
|
36017
|
+
// Si on scroll dans la liste elle-même (aucun effet de suppression de liste)
|
|
36018
|
+
if (target.closest && target.closest('.p-dropdown-panel')) {
|
|
36019
|
+
return;
|
|
36020
|
+
}
|
|
36033
36021
|
|
|
36034
|
-
|
|
36022
|
+
// Sinon, on ferme la zone de liste
|
|
36023
|
+
var dropdownPanels = document.querySelectorAll('.p-dropdown-panel');
|
|
36024
|
+
dropdownPanels.forEach(function (panel) {
|
|
36025
|
+
if (panel && panel.style.display !== 'none') {
|
|
36026
|
+
document.body.click();
|
|
36027
|
+
}
|
|
36028
|
+
});
|
|
36029
|
+
};
|
|
36035
36030
|
var loadOptions = /*#__PURE__*/function () {
|
|
36036
36031
|
var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
36037
36032
|
var result, _t;
|
|
@@ -36074,6 +36069,10 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36074
36069
|
};
|
|
36075
36070
|
}();
|
|
36076
36071
|
loadOptions();
|
|
36072
|
+
window.addEventListener('scroll', handleScroll, true);
|
|
36073
|
+
return function () {
|
|
36074
|
+
window.removeEventListener('scroll', handleScroll, true);
|
|
36075
|
+
};
|
|
36077
36076
|
}, [options, isOptionLoadFunction]);
|
|
36078
36077
|
useEffect(function () {
|
|
36079
36078
|
setOptionSelected(value !== null && value !== void 0 ? value : null);
|
|
@@ -36106,7 +36105,8 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36106
36105
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
36107
36106
|
className: "flex align-items-center",
|
|
36108
36107
|
style: {
|
|
36109
|
-
|
|
36108
|
+
padding: '6px 10px',
|
|
36109
|
+
height: 'auto'
|
|
36110
36110
|
}
|
|
36111
36111
|
}, /*#__PURE__*/React__default.createElement("div", {
|
|
36112
36112
|
style: _objectSpread2({
|
|
@@ -36155,7 +36155,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36155
36155
|
var onLazyLoad = /*#__PURE__*/function () {
|
|
36156
36156
|
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(event) {
|
|
36157
36157
|
var _event$filter;
|
|
36158
|
-
var search, _res$options, _res$additional$page, _res$additional, res, newOptions, _t2;
|
|
36158
|
+
var search, currentPage, _res$options, _res$additional$page, _res$additional, res, newOptions, _t2;
|
|
36159
36159
|
return _regenerator().w(function (_context2) {
|
|
36160
36160
|
while (1) switch (_context2.n) {
|
|
36161
36161
|
case 0:
|
|
@@ -36165,20 +36165,21 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36165
36165
|
}
|
|
36166
36166
|
return _context2.a(2);
|
|
36167
36167
|
case 1:
|
|
36168
|
+
search = (_event$filter = event === null || event === void 0 ? void 0 : event.filter) !== null && _event$filter !== void 0 ? _event$filter : filterRef.current;
|
|
36169
|
+
currentPage = currentPageRef.current;
|
|
36168
36170
|
setLoading(true);
|
|
36169
|
-
search = (_event$filter = event === null || event === void 0 ? void 0 : event.filter) !== null && _event$filter !== void 0 ? _event$filter : '';
|
|
36170
36171
|
_context2.p = 2;
|
|
36171
36172
|
_context2.n = 3;
|
|
36172
36173
|
return options(search, loadedOptions, {
|
|
36173
|
-
page:
|
|
36174
|
+
page: currentPage
|
|
36174
36175
|
});
|
|
36175
36176
|
case 3:
|
|
36176
36177
|
res = _context2.v;
|
|
36177
36178
|
newOptions = (_res$options = res === null || res === void 0 ? void 0 : res.options) !== null && _res$options !== void 0 ? _res$options : [];
|
|
36178
36179
|
setLoadedOptions(function (prevOptions) {
|
|
36179
|
-
return [].concat(_toConsumableArray$6(prevOptions), _toConsumableArray$6(newOptions));
|
|
36180
|
+
return currentPage === 1 ? newOptions : [].concat(_toConsumableArray$6(prevOptions), _toConsumableArray$6(newOptions));
|
|
36180
36181
|
});
|
|
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 :
|
|
36182
|
+
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
36183
|
_context2.n = 5;
|
|
36183
36184
|
break;
|
|
36184
36185
|
case 4:
|
|
@@ -36198,6 +36199,18 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36198
36199
|
return _ref4.apply(this, arguments);
|
|
36199
36200
|
};
|
|
36200
36201
|
}();
|
|
36202
|
+
var handleFilter = function handleFilter(event) {
|
|
36203
|
+
var _event$value;
|
|
36204
|
+
var value = (_event$value = event === null || event === void 0 ? void 0 : event.value) !== null && _event$value !== void 0 ? _event$value : '';
|
|
36205
|
+
filterRef.current = value;
|
|
36206
|
+
currentPageRef.current = 1;
|
|
36207
|
+
setLoadedOptions([]);
|
|
36208
|
+
if (isOptionLoadFunction) {
|
|
36209
|
+
onLazyLoad({
|
|
36210
|
+
filter: value
|
|
36211
|
+
});
|
|
36212
|
+
}
|
|
36213
|
+
};
|
|
36201
36214
|
var handleChange = function handleChange(e) {
|
|
36202
36215
|
var newValue = e.value;
|
|
36203
36216
|
setOptionSelected(newValue);
|
|
@@ -36263,15 +36276,21 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36263
36276
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
36264
36277
|
className: "flex flex-col gap-1"
|
|
36265
36278
|
}, /*#__PURE__*/React__default.createElement(Dropdown$1, _extends$A({
|
|
36279
|
+
ref: ref,
|
|
36266
36280
|
value: optionSelected,
|
|
36267
36281
|
options: loadedOptions,
|
|
36268
36282
|
onChange: handleChange,
|
|
36269
36283
|
placeholder: placeholder,
|
|
36270
36284
|
disabled: disabled,
|
|
36271
36285
|
filter: filter,
|
|
36286
|
+
onFilter: handleFilter,
|
|
36272
36287
|
optionLabel: optionLabel,
|
|
36273
36288
|
optionValue: optionValue,
|
|
36274
36289
|
style: style,
|
|
36290
|
+
panelStyle: {
|
|
36291
|
+
maxHeight: 'auto',
|
|
36292
|
+
overflowY: 'auto'
|
|
36293
|
+
},
|
|
36275
36294
|
itemTemplate: optionTemplate,
|
|
36276
36295
|
valueTemplate: valueTemplate,
|
|
36277
36296
|
showClear: showClear,
|
|
@@ -36436,7 +36455,7 @@ var DropdownPresets = {
|
|
|
36436
36455
|
fontFamily: 'Arial'
|
|
36437
36456
|
}
|
|
36438
36457
|
},
|
|
36439
|
-
|
|
36458
|
+
SelectMetaAsyncLoad: {
|
|
36440
36459
|
placeholder: 'Chargement distant simulé',
|
|
36441
36460
|
options: function () {
|
|
36442
36461
|
var _options = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(search, loadedOptions, _ref) {
|
|
@@ -36478,6 +36497,7 @@ var DropdownPresets = {
|
|
|
36478
36497
|
generalIcon: 'pi pi-circle-fill'
|
|
36479
36498
|
},
|
|
36480
36499
|
isSelectMeta: true,
|
|
36500
|
+
showClear: true,
|
|
36481
36501
|
valueStyle: {
|
|
36482
36502
|
fontSize: '14px',
|
|
36483
36503
|
fontFamily: 'Arial'
|
|
@@ -36487,7 +36507,7 @@ var DropdownPresets = {
|
|
|
36487
36507
|
fontFamily: 'Arial'
|
|
36488
36508
|
}
|
|
36489
36509
|
},
|
|
36490
|
-
|
|
36510
|
+
SelectMetaAsyncSearch: {
|
|
36491
36511
|
placeholder: 'Recherchez une option...',
|
|
36492
36512
|
filter: true,
|
|
36493
36513
|
options: function () {
|
|
@@ -36501,8 +36521,7 @@ var DropdownPresets = {
|
|
|
36501
36521
|
_context2.n = 1;
|
|
36502
36522
|
return simulateNetworkDelay();
|
|
36503
36523
|
case 1:
|
|
36504
|
-
|
|
36505
|
-
allOptions = generateOptions(100); // Filtrer les options en fonction de la recherche
|
|
36524
|
+
allOptions = generateOptions(100);
|
|
36506
36525
|
filteredOptions = allOptions.filter(function (opt) {
|
|
36507
36526
|
return opt.nom.toLowerCase().includes(search.toLowerCase());
|
|
36508
36527
|
}); // Pagination des résultats filtrés
|
|
@@ -36531,7 +36550,7 @@ var DropdownPresets = {
|
|
|
36531
36550
|
}(),
|
|
36532
36551
|
isSelectMeta: true,
|
|
36533
36552
|
selectMetaConfig: {
|
|
36534
|
-
generalIcon: 'pi
|
|
36553
|
+
generalIcon: 'pi-circle-fill'
|
|
36535
36554
|
},
|
|
36536
36555
|
valueStyle: {
|
|
36537
36556
|
fontSize: '14px',
|
|
@@ -36540,7 +36559,8 @@ var DropdownPresets = {
|
|
|
36540
36559
|
optionStyle: {
|
|
36541
36560
|
fontSize: '14px',
|
|
36542
36561
|
fontFamily: 'Arial'
|
|
36543
|
-
}
|
|
36562
|
+
},
|
|
36563
|
+
showClear: true
|
|
36544
36564
|
},
|
|
36545
36565
|
Group: {
|
|
36546
36566
|
placeholder: 'Veuillez choisir une option',
|