arengibook 2.4.646 → 2.4.648
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 +66 -72
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -39260,7 +39260,8 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
|
|
|
39260
39260
|
options: []
|
|
39261
39261
|
};
|
|
39262
39262
|
case 5:
|
|
39263
|
-
setLoadedOptions(
|
|
39263
|
+
// setLoadedOptions(result?.options || []);
|
|
39264
|
+
setLoadedOptions(_flattenOptions(((_result = result) === null || _result === void 0 ? void 0 : _result.options) || []));
|
|
39264
39265
|
if (objValue) {
|
|
39265
39266
|
exists = (_result2 = result) === null || _result2 === void 0 || (_result2 = _result2.options) === null || _result2 === void 0 ? void 0 : _result2.some(function (opt) {
|
|
39266
39267
|
return opt[optionValue] === objValue[optionValue];
|
|
@@ -39346,38 +39347,76 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
|
|
|
39346
39347
|
style: styleLabel
|
|
39347
39348
|
}, option[optionLabel]));
|
|
39348
39349
|
};
|
|
39349
|
-
var selectedItemTemplate = function selectedItemTemplate(option) {
|
|
39350
|
-
var _selectedOption, _selectedOption2, _selectedOption3, _selectedOption4;
|
|
39351
|
-
// const selectedOption = objValue.find(opt => opt[optionValue] === option);
|
|
39352
39350
|
|
|
39351
|
+
// const selectedItemTemplate = (option) => {
|
|
39352
|
+
//
|
|
39353
|
+
// const selectedOption = objValue.find(opt => opt[optionValue] === option);
|
|
39354
|
+
// if (!selectedOption) return null;
|
|
39355
|
+
// // const isLastItem = index === selectedOptions.length - 1;
|
|
39356
|
+
// const handleRemove = (e) => {
|
|
39357
|
+
// e.stopPropagation();
|
|
39358
|
+
// const newSelectedOptions = selectedOptions.filter(opt => opt !== option);
|
|
39359
|
+
// setSelectedOptions(newSelectedOptions);
|
|
39360
|
+
// if (onChange) onChange(newSelectedOptions);
|
|
39361
|
+
// };
|
|
39362
|
+
//
|
|
39363
|
+
// return (
|
|
39364
|
+
// <span
|
|
39365
|
+
// onClick={handleRemove}
|
|
39366
|
+
// style={{
|
|
39367
|
+
// backgroundColor: selectedOption?.color ? selectedOption?.color : '#f8e6ec',
|
|
39368
|
+
// color: selectedOption?.color ? inverseColor(selectedOption?.color) : '#333',
|
|
39369
|
+
// padding: '6px 12px',
|
|
39370
|
+
// fontSize: '14px',
|
|
39371
|
+
// borderRadius: '8px',
|
|
39372
|
+
// boxShadow: '2px 2px 4px rgba(0, 0, 0, 0.15)',
|
|
39373
|
+
// display: 'inline-block',
|
|
39374
|
+
// marginBottom: '5px',
|
|
39375
|
+
// fontFamily: 'Arial',
|
|
39376
|
+
// cursor: 'pointer',
|
|
39377
|
+
// marginRight: '15px',
|
|
39378
|
+
// ...valueStyle,
|
|
39379
|
+
// }}
|
|
39380
|
+
// >
|
|
39381
|
+
// {selectedOption[optionLabel]}
|
|
39382
|
+
// <span style={{ marginLeft: '5px' }}>×</span>
|
|
39383
|
+
// </span>
|
|
39384
|
+
// );
|
|
39385
|
+
//
|
|
39386
|
+
//
|
|
39387
|
+
// };
|
|
39388
|
+
|
|
39389
|
+
var _flattenOptions = function flattenOptions(options) {
|
|
39390
|
+
if (!Array.isArray(options)) return [];
|
|
39391
|
+
return options.reduce(function (acc, item) {
|
|
39392
|
+
if (Array.isArray(item)) {
|
|
39393
|
+
acc.push.apply(acc, _toConsumableArray$7(_flattenOptions(item))); // récursion
|
|
39394
|
+
} else {
|
|
39395
|
+
acc.push(item);
|
|
39396
|
+
}
|
|
39397
|
+
return acc;
|
|
39398
|
+
}, []);
|
|
39399
|
+
};
|
|
39400
|
+
var selectedItemTemplate = function selectedItemTemplate(paramValue, index) {
|
|
39401
|
+
// const selectedOption = loadedOptions.find(opt => opt[optionValue] === paramValue);
|
|
39402
|
+
var selectedOption = loadedOptions.find(function (opt) {
|
|
39403
|
+
return opt[optionValue] === paramValue;
|
|
39404
|
+
});
|
|
39353
39405
|
console.log("ecoute de selectedOption");
|
|
39354
39406
|
console.log(loadedOptions.find(function (opt) {
|
|
39355
|
-
return opt[optionValue] ===
|
|
39356
|
-
}));
|
|
39357
|
-
console.log(loadedOptions.find(function (opt) {
|
|
39358
|
-
return Number(opt[optionValue]) === Number(option);
|
|
39407
|
+
return opt[optionValue] === paramValue;
|
|
39359
39408
|
}));
|
|
39409
|
+
console.log(selectedOption);
|
|
39360
39410
|
console.log(objValue);
|
|
39411
|
+
console.log(paramValue);
|
|
39361
39412
|
console.log(selectedOptions);
|
|
39362
39413
|
console.log(loadedOptions);
|
|
39363
|
-
console.log(option);
|
|
39364
|
-
|
|
39365
|
-
// 1. Cherche d'abord dans objValue (pour l'affichage immédiat)
|
|
39366
|
-
var selectedOption = objValue.find(function (opt) {
|
|
39367
|
-
return opt[optionValue] === option;
|
|
39368
|
-
});
|
|
39369
|
-
// 2. Si non trouvé, cherche dans loadedOptions (pour les cas où objValue est obsolète)
|
|
39370
|
-
if (!selectedOption && loadedOptions.length > 0) {
|
|
39371
|
-
selectedOption = loadedOptions.find(function (opt) {
|
|
39372
|
-
return opt[optionValue] === option;
|
|
39373
|
-
});
|
|
39374
|
-
}
|
|
39375
|
-
console.log(selectedOption);
|
|
39376
39414
|
if (!selectedOption) return null;
|
|
39415
|
+
// const isLastItem = index === selectedOptions.length - 1;
|
|
39377
39416
|
var handleRemove = function handleRemove(e) {
|
|
39378
39417
|
e.stopPropagation();
|
|
39379
39418
|
var newSelectedOptions = selectedOptions.filter(function (opt) {
|
|
39380
|
-
return opt !==
|
|
39419
|
+
return opt !== paramValue;
|
|
39381
39420
|
});
|
|
39382
39421
|
setSelectedOptions(newSelectedOptions);
|
|
39383
39422
|
if (onChange) onChange(newSelectedOptions);
|
|
@@ -39385,8 +39424,8 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
|
|
|
39385
39424
|
return /*#__PURE__*/React__default.createElement("span", {
|
|
39386
39425
|
onClick: handleRemove,
|
|
39387
39426
|
style: _objectSpread2({
|
|
39388
|
-
backgroundColor:
|
|
39389
|
-
color:
|
|
39427
|
+
backgroundColor: selectedOption !== null && selectedOption !== void 0 && selectedOption.color ? selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.color : '#f8e6ec',
|
|
39428
|
+
color: selectedOption !== null && selectedOption !== void 0 && selectedOption.color ? inverseColor(selectedOption === null || selectedOption === void 0 ? void 0 : selectedOption.color) : '#333',
|
|
39390
39429
|
padding: '6px 12px',
|
|
39391
39430
|
fontSize: '14px',
|
|
39392
39431
|
borderRadius: '8px',
|
|
@@ -39404,52 +39443,6 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
|
|
|
39404
39443
|
}, "\xD7"));
|
|
39405
39444
|
};
|
|
39406
39445
|
|
|
39407
|
-
// const selectedItemTemplate = (paramValue, index) => {
|
|
39408
|
-
// // const selectedOption = loadedOptions.find(opt => opt[optionValue] === paramValue);
|
|
39409
|
-
// const selectedOption = objValue.find(opt => opt[optionValue] === paramValue);
|
|
39410
|
-
//
|
|
39411
|
-
// console.log("ecoute de selectedOption")
|
|
39412
|
-
// console.log(loadedOptions.find(opt => opt[optionValue] === paramValue))
|
|
39413
|
-
// console.log(selectedOption)
|
|
39414
|
-
// console.log(objValue)
|
|
39415
|
-
// console.log(paramValue)
|
|
39416
|
-
// console.log(selectedOptions)
|
|
39417
|
-
// console.log(loadedOptions)
|
|
39418
|
-
//
|
|
39419
|
-
// if (!selectedOption) return null;
|
|
39420
|
-
// // const isLastItem = index === selectedOptions.length - 1;
|
|
39421
|
-
// const handleRemove = (e) => {
|
|
39422
|
-
// e.stopPropagation();
|
|
39423
|
-
// const newSelectedOptions = selectedOptions.filter(opt => opt !== paramValue);
|
|
39424
|
-
// setSelectedOptions(newSelectedOptions);
|
|
39425
|
-
// if (onChange) onChange(newSelectedOptions);
|
|
39426
|
-
// };
|
|
39427
|
-
//
|
|
39428
|
-
// return (
|
|
39429
|
-
// <span
|
|
39430
|
-
// onClick={handleRemove}
|
|
39431
|
-
// style={{
|
|
39432
|
-
// backgroundColor: selectedOption?.color ? selectedOption?.color : '#f8e6ec',
|
|
39433
|
-
// color: selectedOption?.color ? inverseColor(selectedOption?.color) : '#333',
|
|
39434
|
-
// padding: '6px 12px',
|
|
39435
|
-
// fontSize: '14px',
|
|
39436
|
-
// borderRadius: '8px',
|
|
39437
|
-
// boxShadow: '2px 2px 4px rgba(0, 0, 0, 0.15)',
|
|
39438
|
-
// display: 'inline-block',
|
|
39439
|
-
// marginBottom: '5px',
|
|
39440
|
-
// fontFamily: 'Arial',
|
|
39441
|
-
// cursor: 'pointer',
|
|
39442
|
-
// marginRight: '15px',
|
|
39443
|
-
// ...valueStyle,
|
|
39444
|
-
// }}
|
|
39445
|
-
// >
|
|
39446
|
-
// {selectedOption[optionLabel]}
|
|
39447
|
-
// <span style={{ marginLeft: '5px' }}>×</span>
|
|
39448
|
-
// </span>
|
|
39449
|
-
// );
|
|
39450
|
-
//
|
|
39451
|
-
// };
|
|
39452
|
-
|
|
39453
39446
|
// Fonction de lazy loading
|
|
39454
39447
|
var onLazyLoad = function onLazyLoad(event) {
|
|
39455
39448
|
if (isOptionsArray) return;
|
|
@@ -39501,7 +39494,8 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
|
|
|
39501
39494
|
_items[i] = newOptions[i - first];
|
|
39502
39495
|
}
|
|
39503
39496
|
}
|
|
39504
|
-
setLoadedOptions(_items);
|
|
39497
|
+
// setLoadedOptions(_items);
|
|
39498
|
+
setLoadedOptions(_flattenOptions(_items));
|
|
39505
39499
|
setLoading(false);
|
|
39506
39500
|
currentPageRef.current += 1;
|
|
39507
39501
|
// Redimensionnement du conteneur
|
|
@@ -39522,7 +39516,7 @@ var MultiSelectMetaAsync = function MultiSelectMetaAsync(_ref) {
|
|
|
39522
39516
|
width: '100%'
|
|
39523
39517
|
}
|
|
39524
39518
|
}, /*#__PURE__*/React__default.createElement(MultiSelect$1, {
|
|
39525
|
-
options: loadedOptions,
|
|
39519
|
+
options: _flattenOptions(loadedOptions),
|
|
39526
39520
|
onChange: handleChange,
|
|
39527
39521
|
style: style,
|
|
39528
39522
|
showSelectAll: showSelectAll,
|