arengibook 2.4.609 → 2.4.610
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 +14 -161
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import * as React from 'react';
|
|
2
|
-
import React__default, { useContext, useEffect, useState, useRef, forwardRef, Fragment
|
|
2
|
+
import React__default, { useContext, useEffect, useState, useRef, forwardRef, Fragment } from 'react';
|
|
3
3
|
import ReactDOM from 'react-dom';
|
|
4
4
|
|
|
5
5
|
function _arrayWithHoles$d(r) {
|
|
@@ -35963,7 +35963,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
35963
35963
|
_ref$objValue = _ref.objValue,
|
|
35964
35964
|
objValue = _ref$objValue === void 0 ? null : _ref$objValue,
|
|
35965
35965
|
_ref$placeholder = _ref.placeholder,
|
|
35966
|
-
placeholder = _ref$placeholder === void 0 ?
|
|
35966
|
+
placeholder = _ref$placeholder === void 0 ? 'Sélectionnez une option' : _ref$placeholder,
|
|
35967
35967
|
_ref$disabled = _ref.disabled,
|
|
35968
35968
|
disabled = _ref$disabled === void 0 ? false : _ref$disabled,
|
|
35969
35969
|
_ref$filter = _ref.filter,
|
|
@@ -35984,8 +35984,6 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
35984
35984
|
onChange = _ref.onChange,
|
|
35985
35985
|
_ref$optionStyle = _ref.optionStyle,
|
|
35986
35986
|
optionStyle = _ref$optionStyle === void 0 ? {} : _ref$optionStyle,
|
|
35987
|
-
_ref$editable = _ref.editable,
|
|
35988
|
-
editable = _ref$editable === void 0 ? false : _ref$editable,
|
|
35989
35987
|
name = _ref.name,
|
|
35990
35988
|
_ref$showClear = _ref.showClear,
|
|
35991
35989
|
showClear = _ref$showClear === void 0 ? false : _ref$showClear,
|
|
@@ -36020,42 +36018,14 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36020
36018
|
_useState6 = _slicedToArray$8(_useState5, 2),
|
|
36021
36019
|
loadedOptions = _useState6[0],
|
|
36022
36020
|
setLoadedOptions = _useState6[1];
|
|
36023
|
-
var isOptionLoadFunction = typeof options === 'function';
|
|
36021
|
+
var isOptionLoadFunction = typeof options === 'function';
|
|
36024
36022
|
var filterRef = useRef('');
|
|
36025
36023
|
var dropdownRef = useRef(null);
|
|
36026
36024
|
var _useState7 = useState(null),
|
|
36027
36025
|
_useState8 = _slicedToArray$8(_useState7, 2),
|
|
36028
36026
|
valueToOptionMap = _useState8[0],
|
|
36029
36027
|
setValueToOptionMap = _useState8[1];
|
|
36030
|
-
var _useState9 = useState(20),
|
|
36031
|
-
_useState0 = _slicedToArray$8(_useState9, 2),
|
|
36032
|
-
inputWidth = _useState0[0];
|
|
36033
|
-
_useState0[1]; // largeur initiale minimale
|
|
36034
|
-
|
|
36035
36028
|
useEffect(function () {
|
|
36036
|
-
// const editableFunction = () => {
|
|
36037
|
-
// if (editable) {
|
|
36038
|
-
// const hiddenInput= document.getElementsByClassName("p-dropdown-label");
|
|
36039
|
-
// hiddenInput[0].setAttribute('type', 'hidden');
|
|
36040
|
-
//
|
|
36041
|
-
// const editableDiv = document.createElement('div');
|
|
36042
|
-
// editableDiv.contentEditable = 'true';
|
|
36043
|
-
// editableDiv.textContent = 'Mon texte ici';
|
|
36044
|
-
//
|
|
36045
|
-
//
|
|
36046
|
-
// editableDiv.style.display = 'inline-block';
|
|
36047
|
-
// editableDiv.style.width = 'auto';
|
|
36048
|
-
// editableDiv.style.padding = '6px 10px';
|
|
36049
|
-
// editableDiv.style.color = 'green';
|
|
36050
|
-
// editableDiv.style.backgroundColor = 'gray';
|
|
36051
|
-
// editableDiv.style.borderRadius = '20px';
|
|
36052
|
-
// editableDiv.style.fontSize = '16px';
|
|
36053
|
-
// editableDiv.style.outline = 'none';
|
|
36054
|
-
// hiddenInput[0].parentNode.insertBefore(editableDiv, hiddenInput[0]);
|
|
36055
|
-
// }
|
|
36056
|
-
// }
|
|
36057
|
-
// editableFunction();
|
|
36058
|
-
|
|
36059
36029
|
if (isOptionLoadFunction && objValue && isSelectMeta) {
|
|
36060
36030
|
setValueToOptionMap(objValue);
|
|
36061
36031
|
}
|
|
@@ -36088,9 +36058,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36088
36058
|
setLoading(true);
|
|
36089
36059
|
_context.p = 1;
|
|
36090
36060
|
_context.n = 2;
|
|
36091
|
-
return options(
|
|
36092
|
-
page: 1
|
|
36093
|
-
});
|
|
36061
|
+
return options();
|
|
36094
36062
|
case 2:
|
|
36095
36063
|
result = _context.v;
|
|
36096
36064
|
setLoadedOptions(Array.isArray(result.options) ? result.options : []);
|
|
@@ -36233,57 +36201,6 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36233
36201
|
}, (option === null || option === void 0 ? void 0 : option[optionLabel]) || placeholder);
|
|
36234
36202
|
}
|
|
36235
36203
|
};
|
|
36236
|
-
|
|
36237
|
-
// const valueTemplate = (option) => {
|
|
36238
|
-
// if (isSelectMeta) {
|
|
36239
|
-
// if (objValue === null) {
|
|
36240
|
-
// const iconColor = option?.color ? inverseColor(option?.color) : '#FFFFFF';
|
|
36241
|
-
// return (<span ref={dropdownRef}>
|
|
36242
|
-
// <div
|
|
36243
|
-
// className={'badge select-badge'}
|
|
36244
|
-
// style={{
|
|
36245
|
-
// backgroundColor: option?.color,
|
|
36246
|
-
// color: iconColor,
|
|
36247
|
-
// padding: '0.5rem',
|
|
36248
|
-
// display: 'inline-block',
|
|
36249
|
-
// ...valueStyle,
|
|
36250
|
-
// }}
|
|
36251
|
-
// >
|
|
36252
|
-
// {option?.[optionLabel] ? (
|
|
36253
|
-
// <span style={{ color: iconColor }}>{option?.[optionLabel]}</span>
|
|
36254
|
-
// ) : (
|
|
36255
|
-
// <span style={{ color: '#000000' }}>{placeholder}</span>
|
|
36256
|
-
// )}
|
|
36257
|
-
// </div>
|
|
36258
|
-
// </span>)
|
|
36259
|
-
// } else if (objValue && valueToOptionMap && typeof objValue === 'object') {
|
|
36260
|
-
// const mappedOption = valueToOptionMap;
|
|
36261
|
-
// const iconColor = mappedOption.color ? inverseColor(mappedOption.color) : '#FFFFFF';
|
|
36262
|
-
// return (
|
|
36263
|
-
// <div
|
|
36264
|
-
// className={'badge select-badge'}
|
|
36265
|
-
// style={{
|
|
36266
|
-
// backgroundColor: mappedOption.color,
|
|
36267
|
-
// color: iconColor,
|
|
36268
|
-
// padding: '0.5rem',
|
|
36269
|
-
// display: 'inline-block',
|
|
36270
|
-
// ...valueStyle,
|
|
36271
|
-
// }}
|
|
36272
|
-
// >
|
|
36273
|
-
// <span style={{ color: iconColor }}>{mappedOption.label}</span>
|
|
36274
|
-
// </div>
|
|
36275
|
-
// );
|
|
36276
|
-
// }
|
|
36277
|
-
//
|
|
36278
|
-
//
|
|
36279
|
-
// } else {
|
|
36280
|
-
// return (
|
|
36281
|
-
// <span style={{ fontFamily: 'Arial', fontSize: '14px', ...valueStyle }}>
|
|
36282
|
-
// {option?.[optionLabel] || placeholder}
|
|
36283
|
-
// </span>
|
|
36284
|
-
// );
|
|
36285
|
-
// }
|
|
36286
|
-
// };
|
|
36287
36204
|
var onLazyLoad = /*#__PURE__*/function () {
|
|
36288
36205
|
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(event) {
|
|
36289
36206
|
var _event$filter;
|
|
@@ -36291,7 +36208,7 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36291
36208
|
return _regenerator().w(function (_context2) {
|
|
36292
36209
|
while (1) switch (_context2.n) {
|
|
36293
36210
|
case 0:
|
|
36294
|
-
if (
|
|
36211
|
+
if (isOptionLoadFunction) {
|
|
36295
36212
|
_context2.n = 1;
|
|
36296
36213
|
break;
|
|
36297
36214
|
}
|
|
@@ -36407,54 +36324,10 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36407
36324
|
}, option.label)));
|
|
36408
36325
|
}
|
|
36409
36326
|
};
|
|
36410
|
-
|
|
36411
|
-
// 🔍 Trouver l’option actuelle (comme valueTemplate)
|
|
36412
|
-
var currentOption = useMemo(function () {
|
|
36413
|
-
var allOptions = Array.isArray(loadedOptions) ? loadedOptions : [];
|
|
36414
|
-
return allOptions.find(function (opt) {
|
|
36415
|
-
return opt[optionValue] === optionSelected;
|
|
36416
|
-
}) || null;
|
|
36417
|
-
}, [loadedOptions, optionSelected, optionValue]);
|
|
36418
|
-
var getTextWidth = function getTextWidth(text, font) {
|
|
36419
|
-
var span = document.createElement('span');
|
|
36420
|
-
span.style.visibility = 'hidden';
|
|
36421
|
-
span.style.whiteSpace = 'pre';
|
|
36422
|
-
span.style.position = 'absolute';
|
|
36423
|
-
span.style.font = font;
|
|
36424
|
-
span.textContent = text || '';
|
|
36425
|
-
document.body.appendChild(span);
|
|
36426
|
-
var width = span.offsetWidth;
|
|
36427
|
-
document.body.removeChild(span);
|
|
36428
|
-
return width + 16;
|
|
36429
|
-
};
|
|
36430
|
-
var editableInputStyle = useMemo(function () {
|
|
36431
|
-
if (!editable) return {};
|
|
36432
|
-
var bg = (currentOption === null || currentOption === void 0 ? void 0 : currentOption.color) || '#FFFFFF';
|
|
36433
|
-
var iconColor = currentOption !== null && currentOption !== void 0 && currentOption.color ? inverseColor(currentOption.color) : '#000000';
|
|
36434
|
-
return _objectSpread2({
|
|
36435
|
-
backgroundColor: bg,
|
|
36436
|
-
color: iconColor,
|
|
36437
|
-
padding: '0.5rem',
|
|
36438
|
-
borderRadius: '1rem',
|
|
36439
|
-
width: getTextWidth(currentOption === null || currentOption === void 0 ? void 0 : currentOption.label),
|
|
36440
|
-
marginRight: '16px'
|
|
36441
|
-
}, valueStyle);
|
|
36442
|
-
}, [editable, currentOption, inputWidth, valueStyle]);
|
|
36443
|
-
var handleEditableChange = function handleEditableChange(e) {
|
|
36444
|
-
var text = e.target.value;
|
|
36445
|
-
if (!text || text.trim() === "") {
|
|
36446
|
-
setOptionSelected(null);
|
|
36447
|
-
if (onChange) onChange(null);
|
|
36448
|
-
} else {
|
|
36449
|
-
setOptionSelected(text);
|
|
36450
|
-
if (onChange) onChange(text);
|
|
36451
|
-
}
|
|
36452
|
-
};
|
|
36453
36327
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
36454
36328
|
className: "flex flex-col gap-1"
|
|
36455
36329
|
}, /*#__PURE__*/React__default.createElement(Dropdown$1, _extends$A({
|
|
36456
36330
|
value: optionSelected,
|
|
36457
|
-
valueTemplate: valueTemplate,
|
|
36458
36331
|
options: loadedOptions,
|
|
36459
36332
|
onChange: handleChange,
|
|
36460
36333
|
placeholder: placeholder,
|
|
@@ -36469,39 +36342,20 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36469
36342
|
overflowY: 'auto'
|
|
36470
36343
|
},
|
|
36471
36344
|
itemTemplate: optionTemplate,
|
|
36345
|
+
valueTemplate: valueTemplate,
|
|
36472
36346
|
showClear: showClear,
|
|
36473
|
-
optionGroupTemplate: isGroupedOption ? groupedItemTemplate : null
|
|
36474
|
-
editable: editable
|
|
36475
|
-
}, editable && {
|
|
36476
|
-
editable: editable,
|
|
36477
|
-
pt: {
|
|
36478
|
-
input: {
|
|
36479
|
-
className: 'badge select-badge',
|
|
36480
|
-
style: editableInputStyle
|
|
36481
|
-
},
|
|
36482
|
-
root: {
|
|
36483
|
-
style: {
|
|
36484
|
-
border: '1px solid #ccc',
|
|
36485
|
-
width: '100%',
|
|
36486
|
-
display: 'inline-flex',
|
|
36487
|
-
alignItems: 'center',
|
|
36488
|
-
justifyContent: 'flex-start',
|
|
36489
|
-
padding: '0.25rem 0.5rem'
|
|
36490
|
-
}
|
|
36491
|
-
}
|
|
36492
|
-
},
|
|
36493
|
-
onInput: handleEditableChange
|
|
36347
|
+
optionGroupTemplate: isGroupedOption ? groupedItemTemplate : null
|
|
36494
36348
|
}, isGroupedOption && {
|
|
36495
36349
|
optionGroupLabel: 'label',
|
|
36496
36350
|
optionGroupChildren: 'items'
|
|
36497
36351
|
}, (isSelectMeta || isOptionLoadFunction) && {
|
|
36498
36352
|
virtualScrollerOptions: {
|
|
36499
|
-
|
|
36353
|
+
lazy: true,
|
|
36500
36354
|
onLazyLoad: onLazyLoad,
|
|
36501
36355
|
itemSize: 38,
|
|
36502
|
-
|
|
36356
|
+
showLoader: true,
|
|
36503
36357
|
loading: loading,
|
|
36504
|
-
|
|
36358
|
+
delay: 250
|
|
36505
36359
|
}
|
|
36506
36360
|
})), name && /*#__PURE__*/React__default.createElement("input", {
|
|
36507
36361
|
type: "hidden",
|
|
@@ -36639,7 +36493,6 @@ var DropdownPresets = {
|
|
|
36639
36493
|
placeholder: 'Sélectionnez une couleur',
|
|
36640
36494
|
options: optionsWithColors,
|
|
36641
36495
|
isSelectMeta: true,
|
|
36642
|
-
editable: false,
|
|
36643
36496
|
selectMetaConfig: {
|
|
36644
36497
|
generalIcon: 'pi pi-circle-fill'
|
|
36645
36498
|
},
|
|
@@ -36654,9 +36507,9 @@ var DropdownPresets = {
|
|
|
36654
36507
|
}
|
|
36655
36508
|
},
|
|
36656
36509
|
SelectMetaAsyncLoad: {
|
|
36657
|
-
|
|
36658
|
-
value:
|
|
36659
|
-
// objValue: { label: 'Option
|
|
36510
|
+
placeholder: 'Chargement distant simulé',
|
|
36511
|
+
value: 20,
|
|
36512
|
+
// objValue: { label: 'Option 2', value: 2, color: 'green' }, // simule un affichage direct de l'option dans l'input si celle-ci a été enregistrée (si options asynchrones uniquement
|
|
36660
36513
|
options: function () {
|
|
36661
36514
|
var _options = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(search, loadedOptions, _ref) {
|
|
36662
36515
|
var page, length, start, data;
|
|
@@ -36664,7 +36517,7 @@ var DropdownPresets = {
|
|
|
36664
36517
|
while (1) switch (_context.n) {
|
|
36665
36518
|
case 0:
|
|
36666
36519
|
page = _ref.page;
|
|
36667
|
-
length =
|
|
36520
|
+
length = 2;
|
|
36668
36521
|
start = (page - 1) * length; // Simule un délai réseau
|
|
36669
36522
|
_context.n = 1;
|
|
36670
36523
|
return new Promise(function (res) {
|