arengibook 2.4.591 → 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.
Files changed (2) hide show
  1. package/dist/index.js +152 -66
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -35948,8 +35948,6 @@ var PopupPresets = {
35948
35948
  var Dropdown = function Dropdown(_ref) {
35949
35949
  var _ref$options = _ref.options,
35950
35950
  options = _ref$options === void 0 ? [] : _ref$options,
35951
- _ref$optionLoad = _ref.optionLoad,
35952
- optionLoad = _ref$optionLoad === void 0 ? null : _ref$optionLoad,
35953
35951
  _ref$isGroupedOption = _ref.isGroupedOption,
35954
35952
  isGroupedOption = _ref$isGroupedOption === void 0 ? false : _ref$isGroupedOption,
35955
35953
  value = _ref.value,
@@ -36000,22 +35998,90 @@ var Dropdown = function Dropdown(_ref) {
36000
35998
  _useState2 = _slicedToArray$8(_useState, 2),
36001
35999
  optionSelected = _useState2[0],
36002
36000
  setOptionSelected = _useState2[1];
36003
- var items = useRef([]);
36001
+ useRef([]);
36004
36002
  var _useState3 = useState(false),
36005
36003
  _useState4 = _slicedToArray$8(_useState3, 2),
36006
36004
  loading = _useState4[0],
36007
36005
  setLoading = _useState4[1];
36008
- var loadedOptionsRef = useRef([]);
36006
+ useRef([]);
36009
36007
  var currentPageRef = useRef(1);
36010
- var isLazy = typeof optionLoad === 'function';
36008
+ var _useState5 = useState([]),
36009
+ _useState6 = _slicedToArray$8(_useState5, 2),
36010
+ loadedOptions = _useState6[0],
36011
+ setLoadedOptions = _useState6[1];
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;
36021
+
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
+ }
36026
+
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
+ var loadOptions = /*#__PURE__*/function () {
36036
+ var _ref2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee() {
36037
+ var result, _t;
36038
+ return _regenerator().w(function (_context) {
36039
+ while (1) switch (_context.n) {
36040
+ case 0:
36041
+ if (!isOptionLoadFunction) {
36042
+ _context.n = 6;
36043
+ break;
36044
+ }
36045
+ setLoading(true);
36046
+ _context.p = 1;
36047
+ _context.n = 2;
36048
+ return options();
36049
+ case 2:
36050
+ result = _context.v;
36051
+ setLoadedOptions(Array.isArray(result.options) ? result.options : []);
36052
+ _context.n = 4;
36053
+ break;
36054
+ case 3:
36055
+ _context.p = 3;
36056
+ _t = _context.v;
36057
+ console.error('Erreur lors du chargement des options:', _t);
36058
+ case 4:
36059
+ _context.p = 4;
36060
+ setLoading(false);
36061
+ return _context.f(4);
36062
+ case 5:
36063
+ _context.n = 7;
36064
+ break;
36065
+ case 6:
36066
+ setLoadedOptions(options);
36067
+ case 7:
36068
+ return _context.a(2);
36069
+ }
36070
+ }, _callee, null, [[1, 3, 4, 5]]);
36071
+ }));
36072
+ return function loadOptions() {
36073
+ return _ref2.apply(this, arguments);
36074
+ };
36075
+ }();
36076
+ loadOptions();
36077
+ window.addEventListener('scroll', handleScroll, true);
36078
+ return function () {
36079
+ window.removeEventListener('scroll', handleScroll, true);
36080
+ };
36081
+ }, [options, isOptionLoadFunction]);
36011
36082
  useEffect(function () {
36012
36083
  setOptionSelected(value !== null && value !== void 0 ? value : null);
36013
36084
  }, [value]);
36014
- useEffect(function () {
36015
- if (!isLazy) {
36016
- items.current = options;
36017
- }
36018
- }, [options, isLazy]);
36019
36085
  var style = {
36020
36086
  border: invalid ? '1px solid red' : '1px solid #ccc',
36021
36087
  width: '100%'
@@ -36035,16 +36101,17 @@ var Dropdown = function Dropdown(_ref) {
36035
36101
  }, optionStyle)
36036
36102
  }, option === null || option === void 0 ? void 0 : option[optionLabel]);
36037
36103
  } else {
36038
- var _ref2 = selectMetaConfig || {},
36039
- labelStyle = _ref2.labelStyle,
36040
- generalIcon = _ref2.generalIcon;
36104
+ var _ref3 = selectMetaConfig || {},
36105
+ labelStyle = _ref3.labelStyle,
36106
+ generalIcon = _ref3.generalIcon;
36041
36107
  var styleLabel = {
36042
36108
  marginLeft: '10px'
36043
36109
  };
36044
36110
  return /*#__PURE__*/React__default.createElement("div", {
36045
36111
  className: "flex align-items-center",
36046
36112
  style: {
36047
- width: '100%'
36113
+ padding: '6px 10px',
36114
+ height: 'auto'
36048
36115
  }
36049
36116
  }, /*#__PURE__*/React__default.createElement("div", {
36050
36117
  style: _objectSpread2({
@@ -36061,6 +36128,8 @@ var Dropdown = function Dropdown(_ref) {
36061
36128
  }, option === null || option === void 0 ? void 0 : option[optionLabel])));
36062
36129
  }
36063
36130
  };
36131
+ ({
36132
+ maxHeight: loadedOptions.length <= 6 ? "".concat(loadedOptions.length * 42, "px") : '240px'});
36064
36133
  var valueTemplate = function valueTemplate(option) {
36065
36134
  if (isSelectMeta) {
36066
36135
  var iconColor = option !== null && option !== void 0 && option.color ? inverseColor(option === null || option === void 0 ? void 0 : option.color) : '#FFFFFF';
@@ -36091,50 +36160,64 @@ var Dropdown = function Dropdown(_ref) {
36091
36160
  }
36092
36161
  };
36093
36162
  var onLazyLoad = /*#__PURE__*/function () {
36094
- var _ref3 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(event) {
36163
+ var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(event) {
36095
36164
  var _event$filter;
36096
- var search, _res$options, _res$additional$page, _res$additional, res, newOptions, _t;
36097
- return _regenerator().w(function (_context) {
36098
- while (1) switch (_context.n) {
36165
+ var search, currentPage, _res$options, _res$additional$page, _res$additional, res, newOptions, _t2;
36166
+ return _regenerator().w(function (_context2) {
36167
+ while (1) switch (_context2.n) {
36099
36168
  case 0:
36100
- if (!(!isLazy || !optionLoad)) {
36101
- _context.n = 1;
36169
+ if (isOptionLoadFunction) {
36170
+ _context2.n = 1;
36102
36171
  break;
36103
36172
  }
36104
- return _context.a(2);
36173
+ return _context2.a(2);
36105
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;
36106
36177
  setLoading(true);
36107
- search = (_event$filter = event === null || event === void 0 ? void 0 : event.filter) !== null && _event$filter !== void 0 ? _event$filter : '';
36108
- _context.p = 2;
36109
- _context.n = 3;
36110
- return optionLoad(search, loadedOptionsRef.current, {
36111
- page: currentPageRef.current
36178
+ _context2.p = 2;
36179
+ _context2.n = 3;
36180
+ return options(search, loadedOptions, {
36181
+ page: currentPage
36112
36182
  });
36113
36183
  case 3:
36114
- res = _context.v;
36184
+ res = _context2.v;
36115
36185
  newOptions = (_res$options = res === null || res === void 0 ? void 0 : res.options) !== null && _res$options !== void 0 ? _res$options : [];
36116
- loadedOptionsRef.current = [].concat(_toConsumableArray$6(loadedOptionsRef.current), _toConsumableArray$6(newOptions));
36117
- items.current = loadedOptionsRef.current;
36118
- 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 : currentPageRef.current + 1;
36119
- _context.n = 5;
36186
+ setLoadedOptions(function (prevOptions) {
36187
+ return currentPage === 1 ? newOptions : [].concat(_toConsumableArray$6(prevOptions), _toConsumableArray$6(newOptions));
36188
+ });
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;
36190
+ _context2.n = 5;
36120
36191
  break;
36121
36192
  case 4:
36122
- _context.p = 4;
36123
- _t = _context.v;
36124
- console.error('Erreur optionLoad:', _t);
36193
+ _context2.p = 4;
36194
+ _t2 = _context2.v;
36195
+ console.error('Erreur lors du chargement des options:', _t2);
36125
36196
  case 5:
36126
- _context.p = 5;
36197
+ _context2.p = 5;
36127
36198
  setLoading(false);
36128
- return _context.f(5);
36199
+ return _context2.f(5);
36129
36200
  case 6:
36130
- return _context.a(2);
36201
+ return _context2.a(2);
36131
36202
  }
36132
- }, _callee, null, [[2, 4, 5, 6]]);
36203
+ }, _callee2, null, [[2, 4, 5, 6]]);
36133
36204
  }));
36134
36205
  return function onLazyLoad(_x) {
36135
- return _ref3.apply(this, arguments);
36206
+ return _ref4.apply(this, arguments);
36136
36207
  };
36137
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
+ };
36138
36221
  var handleChange = function handleChange(e) {
36139
36222
  var newValue = e.value;
36140
36223
  setOptionSelected(newValue);
@@ -36143,15 +36226,15 @@ var Dropdown = function Dropdown(_ref) {
36143
36226
  }
36144
36227
  };
36145
36228
  var groupedItemTemplate = function groupedItemTemplate(option) {
36146
- var _ref4 = groupedItemTemplateConfig || {},
36147
- showImage = _ref4.showImage,
36148
- imageKey = _ref4.imageKey,
36149
- imageStyle = _ref4.imageStyle,
36150
- showIcon = _ref4.showIcon,
36151
- iconKey = _ref4.iconKey,
36152
- labelStyle = _ref4.labelStyle,
36153
- generalIcon = _ref4.generalIcon,
36154
- generalImage = _ref4.generalImage;
36229
+ var _ref5 = groupedItemTemplateConfig || {},
36230
+ showImage = _ref5.showImage,
36231
+ imageKey = _ref5.imageKey,
36232
+ imageStyle = _ref5.imageStyle,
36233
+ showIcon = _ref5.showIcon,
36234
+ iconKey = _ref5.iconKey,
36235
+ labelStyle = _ref5.labelStyle,
36236
+ generalIcon = _ref5.generalIcon,
36237
+ generalImage = _ref5.generalImage;
36155
36238
  var icon = option.value && option.value[iconKey];
36156
36239
  var styleLabel = generalIcon || showImage && option[imageKey] || showIcon && icon ? {
36157
36240
  marginLeft: '10px'
@@ -36201,14 +36284,19 @@ var Dropdown = function Dropdown(_ref) {
36201
36284
  className: "flex flex-col gap-1"
36202
36285
  }, /*#__PURE__*/React__default.createElement(Dropdown$1, _extends$A({
36203
36286
  value: optionSelected,
36204
- options: isLazy ? items.current : options,
36287
+ options: loadedOptions,
36205
36288
  onChange: handleChange,
36206
36289
  placeholder: placeholder,
36207
36290
  disabled: disabled,
36208
36291
  filter: filter,
36292
+ onFilter: handleFilter,
36209
36293
  optionLabel: optionLabel,
36210
36294
  optionValue: optionValue,
36211
36295
  style: style,
36296
+ panelStyle: {
36297
+ maxHeight: 'auto',
36298
+ overflowY: 'auto'
36299
+ },
36212
36300
  itemTemplate: optionTemplate,
36213
36301
  valueTemplate: valueTemplate,
36214
36302
  showClear: showClear,
@@ -36216,7 +36304,7 @@ var Dropdown = function Dropdown(_ref) {
36216
36304
  }, isGroupedOption && {
36217
36305
  optionGroupLabel: 'label',
36218
36306
  optionGroupChildren: 'items'
36219
- }, (isSelectMeta || isLazy) && {
36307
+ }, (isSelectMeta || isOptionLoadFunction) && {
36220
36308
  virtualScrollerOptions: {
36221
36309
  lazy: true,
36222
36310
  onLazyLoad: onLazyLoad,
@@ -36375,9 +36463,8 @@ var DropdownPresets = {
36375
36463
  },
36376
36464
  AsyncLoad: {
36377
36465
  placeholder: 'Chargement distant simulé',
36378
- options: [],
36379
- optionLoad: function () {
36380
- var _optionLoad = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(search, loadedOptions, _ref) {
36466
+ options: function () {
36467
+ var _options = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(search, loadedOptions, _ref) {
36381
36468
  var page, length, start, data;
36382
36469
  return _regenerator().w(function (_context) {
36383
36470
  while (1) switch (_context.n) {
@@ -36400,7 +36487,6 @@ var DropdownPresets = {
36400
36487
  });
36401
36488
  }),
36402
36489
  hasMore: page * length < 100,
36403
- // Supposons que nous avons 100 options au total
36404
36490
  additional: {
36405
36491
  page: page + 1
36406
36492
  }
@@ -36408,15 +36494,16 @@ var DropdownPresets = {
36408
36494
  }
36409
36495
  }, _callee);
36410
36496
  }));
36411
- function optionLoad(_x, _x2, _x3) {
36412
- return _optionLoad.apply(this, arguments);
36497
+ function options(_x, _x2, _x3) {
36498
+ return _options.apply(this, arguments);
36413
36499
  }
36414
- return optionLoad;
36500
+ return options;
36415
36501
  }(),
36416
36502
  selectMetaConfig: {
36417
36503
  generalIcon: 'pi pi-circle-fill'
36418
36504
  },
36419
36505
  isSelectMeta: true,
36506
+ showClear: true,
36420
36507
  valueStyle: {
36421
36508
  fontSize: '14px',
36422
36509
  fontFamily: 'Arial'
@@ -36429,9 +36516,8 @@ var DropdownPresets = {
36429
36516
  AsyncSearch: {
36430
36517
  placeholder: 'Recherchez une option...',
36431
36518
  filter: true,
36432
- options: [],
36433
- optionLoad: function () {
36434
- var _optionLoad2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(search, loadedOptions, _ref2) {
36519
+ options: function () {
36520
+ var _options2 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(search, loadedOptions, _ref2) {
36435
36521
  var page, length, allOptions, filteredOptions, start, pageSlice;
36436
36522
  return _regenerator().w(function (_context2) {
36437
36523
  while (1) switch (_context2.n) {
@@ -36441,8 +36527,7 @@ var DropdownPresets = {
36441
36527
  _context2.n = 1;
36442
36528
  return simulateNetworkDelay();
36443
36529
  case 1:
36444
- // Générer toutes les options possibles
36445
- allOptions = generateOptions(100); // Filtrer les options en fonction de la recherche
36530
+ allOptions = generateOptions(100);
36446
36531
  filteredOptions = allOptions.filter(function (opt) {
36447
36532
  return opt.nom.toLowerCase().includes(search.toLowerCase());
36448
36533
  }); // Pagination des résultats filtrés
@@ -36464,10 +36549,10 @@ var DropdownPresets = {
36464
36549
  }
36465
36550
  }, _callee2);
36466
36551
  }));
36467
- function optionLoad(_x4, _x5, _x6) {
36468
- return _optionLoad2.apply(this, arguments);
36552
+ function options(_x4, _x5, _x6) {
36553
+ return _options2.apply(this, arguments);
36469
36554
  }
36470
- return optionLoad;
36555
+ return options;
36471
36556
  }(),
36472
36557
  isSelectMeta: true,
36473
36558
  selectMetaConfig: {
@@ -36480,7 +36565,8 @@ var DropdownPresets = {
36480
36565
  optionStyle: {
36481
36566
  fontSize: '14px',
36482
36567
  fontFamily: 'Arial'
36483
- }
36568
+ },
36569
+ showClear: true
36484
36570
  },
36485
36571
  Group: {
36486
36572
  placeholder: 'Veuillez choisir une option',
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "arengibook",
3
3
  "private": false,
4
- "version": "2.4.591",
4
+ "version": "2.4.593",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
7
  "exports": {