arengibook 2.4.607 → 2.4.609
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 +147 -12
- 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 } from 'react';
|
|
2
|
+
import React__default, { useContext, useEffect, useState, useRef, forwardRef, Fragment, useMemo } from 'react';
|
|
3
3
|
import ReactDOM from 'react-dom';
|
|
4
4
|
|
|
5
5
|
function _arrayWithHoles$d(r) {
|
|
@@ -36027,9 +36027,36 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36027
36027
|
_useState8 = _slicedToArray$8(_useState7, 2),
|
|
36028
36028
|
valueToOptionMap = _useState8[0],
|
|
36029
36029
|
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
|
+
|
|
36030
36035
|
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
|
+
|
|
36031
36059
|
if (isOptionLoadFunction && objValue && isSelectMeta) {
|
|
36032
|
-
console.log("objValue");
|
|
36033
36060
|
setValueToOptionMap(objValue);
|
|
36034
36061
|
}
|
|
36035
36062
|
var handleScroll = function handleScroll(e) {
|
|
@@ -36206,6 +36233,57 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36206
36233
|
}, (option === null || option === void 0 ? void 0 : option[optionLabel]) || placeholder);
|
|
36207
36234
|
}
|
|
36208
36235
|
};
|
|
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
|
+
// };
|
|
36209
36287
|
var onLazyLoad = /*#__PURE__*/function () {
|
|
36210
36288
|
var _ref4 = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee2(event) {
|
|
36211
36289
|
var _event$filter;
|
|
@@ -36329,10 +36407,54 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36329
36407
|
}, option.label)));
|
|
36330
36408
|
}
|
|
36331
36409
|
};
|
|
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
|
+
};
|
|
36332
36453
|
return /*#__PURE__*/React__default.createElement("div", {
|
|
36333
36454
|
className: "flex flex-col gap-1"
|
|
36334
36455
|
}, /*#__PURE__*/React__default.createElement(Dropdown$1, _extends$A({
|
|
36335
36456
|
value: optionSelected,
|
|
36457
|
+
valueTemplate: valueTemplate,
|
|
36336
36458
|
options: loadedOptions,
|
|
36337
36459
|
onChange: handleChange,
|
|
36338
36460
|
placeholder: placeholder,
|
|
@@ -36347,10 +36469,28 @@ var Dropdown = function Dropdown(_ref) {
|
|
|
36347
36469
|
overflowY: 'auto'
|
|
36348
36470
|
},
|
|
36349
36471
|
itemTemplate: optionTemplate,
|
|
36350
|
-
valueTemplate: valueTemplate,
|
|
36351
36472
|
showClear: showClear,
|
|
36352
36473
|
optionGroupTemplate: isGroupedOption ? groupedItemTemplate : null,
|
|
36353
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
|
|
36354
36494
|
}, isGroupedOption && {
|
|
36355
36495
|
optionGroupLabel: 'label',
|
|
36356
36496
|
optionGroupChildren: 'items'
|
|
@@ -36499,7 +36639,7 @@ var DropdownPresets = {
|
|
|
36499
36639
|
placeholder: 'Sélectionnez une couleur',
|
|
36500
36640
|
options: optionsWithColors,
|
|
36501
36641
|
isSelectMeta: true,
|
|
36502
|
-
editable:
|
|
36642
|
+
editable: false,
|
|
36503
36643
|
selectMetaConfig: {
|
|
36504
36644
|
generalIcon: 'pi pi-circle-fill'
|
|
36505
36645
|
},
|
|
@@ -36514,14 +36654,9 @@ var DropdownPresets = {
|
|
|
36514
36654
|
}
|
|
36515
36655
|
},
|
|
36516
36656
|
SelectMetaAsyncLoad: {
|
|
36517
|
-
editable:
|
|
36518
|
-
|
|
36519
|
-
objValue: {
|
|
36520
|
-
label: 'Option 2',
|
|
36521
|
-
value: 2,
|
|
36522
|
-
color: '#000000'
|
|
36523
|
-
},
|
|
36524
|
-
// simule un affichage direct de l'option dans l'input si celle-ci a été enregistrée (si options asynchrones uniquement
|
|
36657
|
+
editable: false,
|
|
36658
|
+
value: 3,
|
|
36659
|
+
// objValue: { label: 'Option 3', value: 3, color: '#000000' }, // simule un affichage direct de l'option dans l'input si celle-ci a été enregistrée (si options asynchrones uniquement
|
|
36525
36660
|
options: function () {
|
|
36526
36661
|
var _options = _asyncToGenerator(/*#__PURE__*/_regenerator().m(function _callee(search, loadedOptions, _ref) {
|
|
36527
36662
|
var page, length, start, data;
|