arengibook 1.2.319-main → 1.2.320-main

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 +53 -31
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -41047,7 +41047,7 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
41047
41047
  _useState4 = _slicedToArray$d(_useState3, 2),
41048
41048
  loadedOptions = _useState4[0],
41049
41049
  setLoadedOptions = _useState4[1];
41050
- var loadedOptionsRef = useRef([]); // toujours à jour, évite les closures stales
41050
+ var loadedOptionsRef = useRef([]);
41051
41051
  var multiSelectRef = useRef(null);
41052
41052
  var containerRef = useRef(null);
41053
41053
  var _useState5 = useState(false),
@@ -41059,8 +41059,6 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
41059
41059
  var currentPageRef = useRef(1);
41060
41060
  var searchTermRef = useRef('');
41061
41061
  var searchTimeout = useRef(null);
41062
-
41063
- // Wrapper qui synchronise state ET ref en un seul appel
41064
41062
  var updateLoadedOptions = function updateLoadedOptions(opts) {
41065
41063
  loadedOptionsRef.current = opts;
41066
41064
  setLoadedOptions(opts);
@@ -41208,7 +41206,7 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
41208
41206
  var loadInitialOptions = /*#__PURE__*/function () {
41209
41207
  var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2() {
41210
41208
  var _result, _result2;
41211
- var result, initialOpts, _result3, exists;
41209
+ var result, initialOpts, existingValues, missingSelected;
41212
41210
  return _regenerator().w(function (_context2) {
41213
41211
  while (1) switch (_context2.n) {
41214
41212
  case 0:
@@ -41244,14 +41242,18 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
41244
41242
  case 5:
41245
41243
  hasMoreRef.current = ((_result = result) === null || _result === void 0 ? void 0 : _result.hasMore) !== false;
41246
41244
  initialOpts = _flattenOptions(((_result2 = result) === null || _result2 === void 0 ? void 0 : _result2.options) || []);
41247
- if (objValue) {
41248
- exists = (_result3 = result) === null || _result3 === void 0 || (_result3 = _result3.options) === null || _result3 === void 0 ? void 0 : _result3.some(function (opt) {
41249
- return opt[optionValue] === objValue[optionValue];
41245
+ if (Array.isArray(numObjValue) && numObjValue.length > 0) {
41246
+ existingValues = new Set(initialOpts.map(function (o) {
41247
+ return String(o[optionValue]);
41248
+ }));
41249
+ missingSelected = numObjValue.filter(function (o) {
41250
+ return !existingValues.has(String(o[optionValue]));
41250
41251
  });
41251
- updateLoadedOptions(exists ? initialOpts : [].concat(_toConsumableArray$a(initialOpts), [objValue]));
41252
+ updateLoadedOptions([].concat(_toConsumableArray$a(initialOpts), _toConsumableArray$a(missingSelected)));
41252
41253
  } else {
41253
41254
  updateLoadedOptions(initialOpts);
41254
41255
  }
41256
+ // ─────────────────────────────────────────────────────────────────
41255
41257
  case 6:
41256
41258
  return _context2.a(2);
41257
41259
  }
@@ -41307,26 +41309,18 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
41307
41309
  }, [loadedOptions, enableItemTooltip]);
41308
41310
  var onLazyLoad = function onLazyLoad(event) {
41309
41311
  if (isOptionsArray) return;
41310
-
41311
- // Toujours acquitter le scroll pour que VirtualScroller puisse réinitialiser
41312
- // son loadingState interne (il attend un changement de props.loading)
41313
41312
  setLoading(true);
41314
-
41315
- // Items déjà chargés (scroll vers le haut ou re-fire) — reset immédiat
41316
- // On utilise -1 pour déclencher le chargement quand on atteint le dernier item chargé
41317
41313
  if (event.last < loadedOptionsRef.current.length - 1 || !hasMoreRef.current) {
41318
41314
  setTimeout(function () {
41319
41315
  return setLoading(false);
41320
41316
  }, 0);
41321
41317
  return;
41322
41318
  }
41323
-
41324
- // Déjà en cours de chargement — le timeout existant s'en chargera
41325
41319
  if (isLoadingRef.current) return;
41326
41320
  isLoadingRef.current = true;
41327
41321
  if (loadLazyTimeout.current) clearTimeout(loadLazyTimeout.current);
41328
41322
  loadLazyTimeout.current = setTimeout(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee3() {
41329
- var _result4, _result5;
41323
+ var _result3, _result4;
41330
41324
  var nextPage, result, newOptions;
41331
41325
  return _regenerator().w(function (_context3) {
41332
41326
  while (1) switch (_context3.n) {
@@ -41363,7 +41357,7 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
41363
41357
  hasMore: false
41364
41358
  };
41365
41359
  case 5:
41366
- newOptions = ((_result4 = result) === null || _result4 === void 0 ? void 0 : _result4.options) || [];
41360
+ newOptions = ((_result3 = result) === null || _result3 === void 0 ? void 0 : _result3.options) || [];
41367
41361
  if (!(newOptions.length === 0)) {
41368
41362
  _context3.n = 6;
41369
41363
  break;
@@ -41373,9 +41367,8 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
41373
41367
  setLoading(false);
41374
41368
  return _context3.a(2);
41375
41369
  case 6:
41376
- // Append — pas d'index-based fill (évite les tableaux sparse)
41377
41370
  updateLoadedOptions([].concat(_toConsumableArray$a(loadedOptionsRef.current), _toConsumableArray$a(newOptions)));
41378
- hasMoreRef.current = ((_result5 = result) === null || _result5 === void 0 ? void 0 : _result5.hasMore) !== false;
41371
+ hasMoreRef.current = ((_result4 = result) === null || _result4 === void 0 ? void 0 : _result4.hasMore) !== false;
41379
41372
  currentPageRef.current = nextPage;
41380
41373
  isLoadingRef.current = false;
41381
41374
  setLoading(false);
@@ -41400,7 +41393,6 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
41400
41393
  };
41401
41394
  var inverseColor = function inverseColor(hexColor) {
41402
41395
  if (!hexColor || !hexColor.startsWith('#')) return '#000000';
41403
- // Normalise hex 3-char (#abc) → 6-char (#aabbcc)
41404
41396
  var hex = hexColor;
41405
41397
  if (hex.length === 4) {
41406
41398
  hex = '#' + hex[1] + hex[1] + hex[2] + hex[2] + hex[3] + hex[3];
@@ -41515,8 +41507,8 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
41515
41507
  searchTermRef.current = search;
41516
41508
  if (searchTimeout.current) clearTimeout(searchTimeout.current);
41517
41509
  searchTimeout.current = setTimeout(/*#__PURE__*/_asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee4() {
41518
- var _result6, _result7;
41519
- var result;
41510
+ var _result5, _result6;
41511
+ var result, searchOpts, existingValues, missingSelected;
41520
41512
  return _regenerator().w(function (_context4) {
41521
41513
  while (1) switch (_context4.n) {
41522
41514
  case 0:
@@ -41555,8 +41547,23 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
41555
41547
  hasMore: false
41556
41548
  };
41557
41549
  case 5:
41558
- hasMoreRef.current = ((_result6 = result) === null || _result6 === void 0 ? void 0 : _result6.hasMore) !== false;
41559
- updateLoadedOptions(_flattenOptions(((_result7 = result) === null || _result7 === void 0 ? void 0 : _result7.options) || []));
41550
+ hasMoreRef.current = ((_result5 = result) === null || _result5 === void 0 ? void 0 : _result5.hasMore) !== false;
41551
+
41552
+ // ─── On réinjecte les sélectionnés absents des résultats de recherche ──
41553
+ searchOpts = _flattenOptions(((_result6 = result) === null || _result6 === void 0 ? void 0 : _result6.options) || []);
41554
+ if (Array.isArray(numObjValue) && numObjValue.length > 0) {
41555
+ existingValues = new Set(searchOpts.map(function (o) {
41556
+ return String(o[optionValue]);
41557
+ }));
41558
+ missingSelected = numObjValue.filter(function (o) {
41559
+ return !existingValues.has(String(o[optionValue]));
41560
+ });
41561
+ updateLoadedOptions([].concat(_toConsumableArray$a(searchOpts), _toConsumableArray$a(missingSelected)));
41562
+ } else {
41563
+ updateLoadedOptions(searchOpts);
41564
+ }
41565
+ // ────────────────────────────────────────────────────────────────────────
41566
+
41560
41567
  setLoading(false);
41561
41568
  case 6:
41562
41569
  return _context4.a(2);
@@ -41693,6 +41700,8 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
41693
41700
  return o[optionValue] === paramValue;
41694
41701
  }) || flatOptions.find(function (o) {
41695
41702
  return o.value === paramValue;
41703
+ }) || numObjValue.find(function (o) {
41704
+ return o[optionValue] === paramValue;
41696
41705
  });
41697
41706
  if (!opt) return null;
41698
41707
  return /*#__PURE__*/React__default.createElement("span", {
@@ -41714,7 +41723,10 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
41714
41723
  var _key = String(getKey(paramValue));
41715
41724
  var _selectedOption = flatOptions.find(function (o) {
41716
41725
  return String(o[optionValue]) === _key;
41726
+ }) || numObjValue.find(function (o) {
41727
+ return String(o[optionValue]) === _key;
41717
41728
  });
41729
+ // ─────────────────────────────────────────────────────────────────
41718
41730
  if (!_selectedOption) return null;
41719
41731
  var _objMatch = Array.isArray(objValue) ? objValue.find(function (o) {
41720
41732
  return String(o[optionValue]) === _key;
@@ -41756,6 +41768,8 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
41756
41768
  var key = String(getKey(paramValue));
41757
41769
  var selectedOption = flatOptions.find(function (o) {
41758
41770
  return String(o[optionValue]) === key;
41771
+ }) || numObjValue.find(function (o) {
41772
+ return String(o[optionValue]) === key;
41759
41773
  });
41760
41774
  if (!selectedOption) return null;
41761
41775
  var objMatch = Array.isArray(objValue) ? objValue.find(function (o) {
@@ -41781,13 +41795,12 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
41781
41795
  var key = String(_typeof$g(opt) === 'object' ? opt[optionValue] : opt);
41782
41796
  var found = flatOptions.find(function (o) {
41783
41797
  return String(o[optionValue]) === key;
41798
+ }) || numObjValue.find(function (o) {
41799
+ return String(o[optionValue]) === key;
41784
41800
  });
41785
41801
  return found ? found[optionLabel] : key;
41786
41802
  }).join('\n');
41787
41803
  };
41788
-
41789
- // ─── Panel header / footer ────────────────────────────────────────────────
41790
-
41791
41804
  var selectedOptionsCount = selectedOptions ? selectedOptions.length : 0;
41792
41805
  var totalItemCount = computedOptions.length;
41793
41806
  var customPanelHeader = function customPanelHeader(opts) {
@@ -42048,8 +42061,11 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
42048
42061
  pt: {
42049
42062
  token: function token(_ref9) {
42050
42063
  var context = _ref9.context;
42064
+ var valStr = String(context.value);
42051
42065
  var opt = flatOptions.find(function (o) {
42052
- return o[optionValue] === context.value;
42066
+ return String(o[optionValue]) === valStr;
42067
+ }) || numObjValue.find(function (o) {
42068
+ return String(o[optionValue]) === valStr;
42053
42069
  });
42054
42070
  return {
42055
42071
  style: displayBadge && opt !== null && opt !== void 0 && opt.color ? {
@@ -42065,8 +42081,11 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
42065
42081
  var context = _ref0.context;
42066
42082
  return {
42067
42083
  style: function () {
42084
+ var valStr = String(context.value);
42068
42085
  var opt = flatOptions.find(function (o) {
42069
- return o[optionValue] === context.value;
42086
+ return String(o[optionValue]) === valStr;
42087
+ }) || numObjValue.find(function (o) {
42088
+ return String(o[optionValue]) === valStr;
42070
42089
  });
42071
42090
  return displayBadge && withColor && opt !== null && opt !== void 0 && opt.color ? {
42072
42091
  color: inverseColor(opt.color)
@@ -42095,8 +42114,11 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
42095
42114
  })), /*#__PURE__*/React__default.createElement("span", {
42096
42115
  className: "ms-counter-label",
42097
42116
  "data-pr-tooltip": (selectedOptions || []).map(function (val) {
42117
+ var valStr = String(val);
42098
42118
  var opt = flatOptions.find(function (o) {
42099
- return o[optionValue] === val;
42119
+ return String(o[optionValue]) === valStr;
42120
+ }) || numObjValue.find(function (o) {
42121
+ return String(o[optionValue]) === valStr;
42100
42122
  });
42101
42123
  return (opt === null || opt === void 0 ? void 0 : opt[optionLabel]) || val;
42102
42124
  }).join('\n'),
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "arengibook",
3
3
  "private": false,
4
- "version": "1.2.319-main",
4
+ "version": "1.2.320-main",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.js",
7
7
  "exports": {